Because the length of the string is very short, so the violence enumerates every empty letter, the output of the line appears. Such a simple idea I unexpectedly, on-the-spot thought a lot, thought has any skill, the more wants the more fascinated ... Is the way of thinking problems, encountered problems first analysis of the most simple and brutal approach, and then step by step optimization, can not blindly think.
This problem requires a familiarity with the various uses of the string to be AC fast. Here's a simple summary: the common use of string in C + +.
#include <iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<string>#include<cmath>#include<map>#include<Set>#include<vector>#include<algorithm>#include<stack>#include<queue>#include<cctype>#include<sstream>using namespacestd;#definePII pair<int,int>#defineLL Long Long intConst inteps=1e-8;Const intinf=1000000000;Const intmaxn=0;BOOLYesstringSS) { stringSs2=SS; Reverse (Ss.begin (), Ss.end ()); returnss==SS2;}stringSstr,ans;intMain () {//freopen ("In2.txt", "R", stdin); //freopen ("OUT.txt", "w", stdout);Cin>>Sstr; intn=sstr.length (); for(intI=0; i<=n;i++) { for(CharCh='a'; ch<='Z'; ch++) {ans=Sstr; Ans.insert (Ans.begin ()+i,ch); if(yes (ans)) {cout<<ans<<Endl; return 0; } }} cout<<"NA"<<Endl; //fclose (stdin); //fclose (stdout); return 0;}
Codeforces Round #286 (Div. 2) A. Mr Kitayuta's Gift (brute force, string application)