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;
    }
  • 相关阅读:
    CentOS 软件安装(yum 和 rpm)
    Ubuntu下的 PPPoE 拨号上网方法
    Vim 去除因为 Unix 和 Windows 换行符不同带来的 ^M 问题
    Python 在 Windows 下安装第三方包,报 Python 未注册的问题解决
    scipy 安装错误及解决
    Python 字典一个易犯的错误
    Linux查看系统信息
    系统更新报错--NO_PUBKEY
    关于直播的技术整理2
    关于直播的技术整理
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4657736.html
Copyright © 2011-2022 走看看