Codeforces Round #286 (Div. 2) A. Mr Kitayuta's Gift (violence, string application)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.