codeforces Gym 100187L L. Ministry of Truth 水题
2015-07-18 21:33
369 查看
L. Ministry of Truth
Time Limit: 20 SecMemory Limit: 256 MB
题目连接
http://codeforces.com/gym/100187/problem/KDescription
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.
[b]Input[/b]
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.
[b]Output[/b]
Output the word which should be a result of Andrey's work. If there are several possible such words, output any of them.
[b]Sample Input[/b]
abccabd
[b]Sample Output[/b]
abacaba
HINT
[b]题意[/b]
花费最少,构造回文
[b]题解:[/b]
水题系列……
[b]代码[/b]
#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; }
相关文章推荐
- 【机房重构】最后总结
- POJ 2656 Unhappy Jinjin
- Apache Web Server -> httpd的HTTP的多路处理模块MPM
- lua——基础语法
- Overload、Overwrite和Override
- Flash建立多国语言文档方法
- 原码,补码,反码
- HDU 1102 Constructing Roads(Prim求最小生成树)
- 推荐一个微软的认证 MVP 免费的 不过要付出劳动哟 还有机会受邀到美国总部
- android开发之调试技巧
- android开发之调试技巧
- C语言中的转义符'\d', '\n'相关
- android开发之调试技巧
- Codeforces Gym 100187K K. Perpetuum Mobile 构造
- 跟着vamei复习概率论
- android开发之调试技巧 分类: android 学习笔记 2015-07-18 21:30 140人阅读 评论(0) 收藏
- IOS 学习路线
- 面题3 二维数组的查找
- 黑马程序员————Java基础日常笔记---(图形化用户界面)GUI
- 最近在做政务项目,此种项目,本来并不大,主要原因呢,就是要理好业务需要。