• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            ArcTan

            dfs
            隨筆 - 16, 文章 - 117, 評論 - 6, 引用 - 0
            數據加載中……

            SRM550 DIV2 250PT(字符串水題)

            Problem Statement

                 We have a string originalWord. Each character of originalWord is either 'a' or 'b'. Timmy claims that he can convert it to finalWord using exactly k moves. In each move, he can either change a single 'a' to a 'b', or change a single 'b' to an 'a'.

            You are given the strings originalWord and finalWord, and the int k. Determine whether Timmy may be telling the truth. If there is a possible sequence of exactly k moves that will turn originalWord into finalWord, return "POSSIBLE" (quotes for clarity). Otherwise, return "IMPOSSIBLE".

            Definition

                
            Class: EasyConversionMachine
            Method: isItPossible
            Parameters: string, string, int
            Returns: string
            Method signature: string isItPossible(string originalWord, string finalWord, int k)
            (be sure your method is public)
                

            Notes

            - Timmy may change the same letter multiple times. Each time counts as a different move.

            Constraints

            - originalWord will contain between 1 and 50 characters, inclusive.
            - finalWord and originalWord will contain the same number of characters.
            - Each character in originalWord and finalWord will be 'a' or 'b'.
            - k will be between 1 and 100, inclusive.

            Examples

            0)
                
            "aababba"
            "bbbbbbb"
            2
            Returns: "IMPOSSIBLE"
            It is not possible to reach finalWord in fewer than 4 moves.
            1)
                
            "aabb"
            "aabb"
            1
            Returns: "IMPOSSIBLE"
            The number of moves must be exactly k=1.
            2)
                
            "aaaaabaa"
            "bbbbbabb"
            8
            Returns: "POSSIBLE"
            Use each move to change each of the letters once.
            3)
                
            "aaa"
            "bab"
            4
            Returns: "POSSIBLE"
            The following sequence of 4 moves does the job:
            aaa -> baa -> bab -> aab -> bab
            4)
                
            "aababbabaa"
            "abbbbaabab"
            9
            Returns: "IMPOSSIBLE"

            This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.


            字符串水題!

            249.23PT?。?!

            #include <cstdio>
            #include 
            <cstdlib>
            #include 
            <cstring>
            #include 
            <cmath>
            #include 
            <ctime>
            #include 
            <cassert>
            #include 
            <iostream>
            #include 
            <sstream>
            #include 
            <fstream>
            #include 
            <map>
            #include 
            <set>
            #include 
            <vector>
            #include 
            <queue>
            #include 
            <algorithm>
            #define min(x,y) (x<y?x:y)
            #define max(x,y) (x>y?x:y)
            #define swap(t,x,y) (t=x,x=y,y=t)
            #define clr(list) memset(list,0,sizeof(list))

            using namespace std;

            class EasyConversionMachine{
            public:
                
            string isItPossible(string originalWord, string finalWord, int k)
                {
                    
            int n=originalWord.size();
                    
            int tot=0;
                    
            for (int i=0;i<n;i++)
                        
            if (originalWord[i]!=finalWord[i])
                            tot
            ++;
                    
            if (tot<=&& (k-tot)%2==0) //傻叉,這里剛剛開始搞反了,testing WA了一次
                        
            return "POSSIBLE";
                    
            return "IMPOSSIBLE";
                }
            };

            posted on 2012-07-22 10:02 wangs 閱讀(272) 評論(0)  編輯 收藏 引用 所屬分類: ACM-水題Topcoder

            人妻少妇久久中文字幕一区二区| 亚洲国产美女精品久久久久∴| 国产成人久久精品区一区二区| www.久久热| 色青青草原桃花久久综合| 亚洲人成伊人成综合网久久久| 国产精品一久久香蕉国产线看| 久久久精品久久久久特色影视| 亚洲精品无码久久久久去q| 99久久精品国产一区二区蜜芽 | 久久久久国产精品三级网| 久久天天躁狠狠躁夜夜2020一| 成人久久精品一区二区三区| 亚洲AⅤ优女AV综合久久久| 国产精品久久久福利| 久久精品国产亚洲AV影院| 国产一区二区精品久久凹凸| 99久久99久久久精品齐齐| 久久久久av无码免费网| 欧美性大战久久久久久| 一本久久久久久久| 国产精品免费看久久久| 婷婷久久久亚洲欧洲日产国码AV| 久久人妻少妇嫩草AV蜜桃| 日韩亚洲欧美久久久www综合网| 亚洲人成伊人成综合网久久久| 性高湖久久久久久久久AAAAA| 国产精品无码久久久久| 免费精品99久久国产综合精品| 国产∨亚洲V天堂无码久久久| 久久天堂AV综合合色蜜桃网| 狠狠综合久久AV一区二区三区| 日本加勒比久久精品| 欧美日韩成人精品久久久免费看| 久久九九久精品国产| 青青热久久国产久精品 | 国内精品九九久久久精品| 99蜜桃臀久久久欧美精品网站| 精品久久久久久无码不卡| 亚洲国产精品成人久久蜜臀| 久久影视综合亚洲|