zoukankan      html  css  js  c++  java
  • ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined) A

    2018-02-19
    A. Palindromic Supersequence
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    You are given a string A. Find a string B, where B is a palindrome and A is a subsequence of B.

    A subsequence of a string is a string that can be derived from it by deleting some (not necessarily consecutive) characters without changing the order of the remaining characters. For example, "cotst" is a subsequence of "contest".

    A palindrome is a string that reads the same forward or backward.

    The length of string B should be at most 104. It is guaranteed that there always exists such string.

    You do not need to find the shortest answer, the only restriction is that the length of string B should not exceed 104.

    Input

    First line contains a string A (1 ≤ |A| ≤ 103) consisting of lowercase Latin letters, where |A| is a length of A.

    Output

    Output single line containing B consisting of only lowercase Latin letters. You do not need to find the shortest answer, the only restriction is that the length of string B should not exceed 104. If there are many possible B, print any of them.

    Examples
    input
    aba
    output
    aba
    input
    ab
    output
    aabaa
    Note

    In the first example, "aba" is a subsequence of "aba" which is a palindrome.

    In the second example, "ab" is a subsequence of "aabaa" which is a palindrome.

    感想:大水题 但是 1e3*2=2e3<1e4  一直以为大于后者 导致写了很久 算了 就算学了STL

    code1

    #include<string.h>
    #include<cmath>
    #include<cstdio>
    #include<algorithm>
    #include<iostream>
    #include<vector> 
    #include<queue>
    using namespace std;
    #define MAX 0x3f3f3f3f
    #define fi first
    #define se second
    #define Len 1e8+5
    int main()
    {
        string s,a;       //字符串用string 不是char
        cin>>s;
        cout<<s;
        a.assign(s.rbegin(),s.rend());
        cout<<a<<endl;    //换行不换行是有区别的     
            
    }

    code2

    #include<string.h>
    #include<cmath>
    #include<cstdio>
    #include<algorithm>
    #include<iostream>
    #include<vector> 
    #include<queue>
    using namespace std;
    #define MAX 0x3f3f3f3f
    #define fi first
    #define se second
    #define Len 1e8+5
    int main()
    {
        string s;
        cin>>s;
        cout<<s;
        reverse(s.begin(),s.end()); //
        cout<<s<<endl; 
    }
  • 相关阅读:
    4.2网络层提供的两种服务
    4.1网络层概述
    MATLAB曲面插值及交叉验证
    python爬虫成长之路(二):抓取代理IP并多线程验证
    KNN识别图像上的数字及python实现
    python爬虫成长之路(一):抓取证券之星的股票数据
    YARN环境搭建 之 一:CentOS7.0系统配置
    高效学习方法总结
    《立委随笔:机器学习和自然语言处理》
    XenServer安装虚拟机先扩容存放ISO镜像文件
  • 原文地址:https://www.cnblogs.com/LLbinGG/p/8454286.html
Copyright © 2011-2022 走看看