• <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
            數(shù)據(jù)加載中……

            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!?。?/p>

            #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 閱讀(273) 評論(0)  編輯 收藏 引用 所屬分類: ACM-水題 、Topcoder

            粉嫩小泬无遮挡久久久久久| 99久久免费国产精品热| 国产香蕉97碰碰久久人人| 久久午夜福利电影| 无码国内精品久久综合88| 久久久久人妻一区二区三区| 久久亚洲AV成人出白浆无码国产| 777米奇久久最新地址| 久久久久99精品成人片牛牛影视| 2021国产精品久久精品| 99精品久久精品| 无码人妻久久一区二区三区蜜桃| 国产精品久久一区二区三区| 久久精品中文字幕第23页| 久久久久免费看成人影片| 久久久噜噜噜久久| 久久99热只有频精品8| 性高朝久久久久久久久久| 久久国产精品-国产精品| 色天使久久综合网天天| 2020久久精品国产免费| 狠狠色丁香婷婷久久综合| 国产精品成人无码久久久久久 | 狠狠色丁香婷婷久久综合| 狠狠精品干练久久久无码中文字幕| 午夜精品久久久久久久| 欧美日韩精品久久久久| 久久这里只有精品首页| 久久综合给久久狠狠97色| 伊人久久大香线蕉综合热线| 国产精品无码久久综合网| 国产韩国精品一区二区三区久久| 亚洲国产欧洲综合997久久| 亚洲精品成人网久久久久久| 久久久久女教师免费一区| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 日韩欧美亚洲综合久久影院Ds| 国产亚洲色婷婷久久99精品91 | 日日狠狠久久偷偷色综合0| 精品久久久久久国产三级| 精品久久久久久久久久中文字幕|