码迷,mamicode.com
首页 > 其他好文 > 详细

codeforces Gym 100187L L. Ministry of Truth 水题

时间:2015-07-18 22:27:48      阅读:303      评论:0      收藏:0      [点我收藏+]

标签:

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/gym/100187/problem/K

Description

Andrey works in the Ministry of Truth. His work is changing articles in newspapers and magazines so that they praise the Party and Big Brother.

Recently Big Brother decided that it would be fine if all words in all articles are read equally both from right to left and from left to right. In his opinion it will greatly simplify the reading of articles — even if the word is read in the reverse order, its sense won‘t change.

Andrey spends one second to erase one letter from the word and write another one to its place. Only one word left to be changed, after that he will complete the plan and be able to go home. Of course, he wants to do it as soon as possible. But the truth is that he does not clearly understand right now which word he should get after the replacement. Help him to find it out.

Input

Input contains a single line with the word that Andrey has to change. The word consists of lowercase Latin letters and its length is from 1 to 200000, inclusively.

Output

Output the word which should be a result of Andrey‘s work. If there are several possible such words, output any of them.

Sample Input

abccabd

Sample Output

abacaba

HINT

 

题意

花费最少,构造回文

题解:

水题系列……

代码

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 2000001
#define mod 10007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<0||ch>9){if(ch==-)f=-1;ch=getchar();}
    while(ch>=0&&ch<=9){x=x*10+ch-0;ch=getchar();}
    return x*f;
}
//**************************************************************************************

int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        if(s[i]!=s[s.size()-1-i])
            s[s.size()-1-i]=s[i];
    cout<<s<<endl;
}

 

codeforces Gym 100187L L. Ministry of Truth 水题

标签:

原文地址:http://www.cnblogs.com/qscqesze/p/4657736.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!