zoukankan      html  css  js  c++  java
  • codeforces Gym 100187L L. Ministry of Truth 水题

    L. Ministry of Truth

    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;
    }
  • 相关阅读:
    英语:真正有效的英语学习心得,把英语当母语学习!(转载)
    《2010年年度总结》
    SQL游标使用
    千万数量级分页存储过程
    关于动态创建DOM元素的问题
    MVC3 “从客户端中检测到有潜在危险的 Request.QueryString或者Request.Form 值”问题解决
    记录Ally项目的点点滴滴(一)总结
    解决session丢失问题
    转载:我的外语学习历程(如何学会十门外语)
    C#经典问题总结一
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4657736.html
Copyright © 2011-2022 走看看