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;
    }
  • 相关阅读:
    Android 编译命令 make j8 2>&1 | tee build.log 解释
    Linux时间函数之gettimeofday()函数之使用方法
    转:RSA算法原理说明
    转: 各个密码算法的实现(未验证)
    转:修改Android签名证书keystore的密码、别名alias以及别名密码
    转:Eclipse ADT的Custom debug keystore所需证书规格
    转:如何转换Android打包用jks格式keystore证书为Air用pkcs12格式p12证书
    转: 关于流量控制与令牌桶介绍
    转:sublime2 官方网址
    转:Mac OS X下Sublime Text (V2.0.1)破解
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4657736.html
Copyright © 2011-2022 走看看