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

    占坑,明天写,想把D补出来一起写。2/20/2018 11:17:00 PM

    ----------------------------------------------------------我是分割线-------------------------------------------------------

    我来了,本来打算D题写到一起的,但是有新的东西要写,D就单独写一篇,这里写A,B,C;

    开启智障模式:(看我咸鱼突刺的厉害( • ̀ω•́ )✧)   2/21/2018 10:46:00 PM

    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.

    这道题完全直接就OK,emnnn,哈哈哈,直接倒着再来一遍就可以。

    代码:

     1 //A. Palindromic Supersequence-水题
     2 #include<iostream>
     3 #include<cstring>
     4 #include<cstdio>
     5 #include<cmath>
     6 #include<algorithm>
     7 #include<queue>
     8 using namespace std;
     9 const int maxn=1000+10;
    10 char a[maxn],b[2*maxn];
    11 int main(){
    12     while(~scanf("%s",a)){
    13             memset(b,0,sizeof(b));
    14         int len=strlen(a);
    15         int h=0;
    16         for(int i=0;i<len;i++)
    17             b[h++]=a[i];
    18         for(int i=len-1;i>=0;i--)
    19             b[h++]=a[i];
    20         printf("%s
    ",b);
    21     }
    22     return 0;
    23 }
  • 相关阅读:
    前后端分离
    Do a “git export” (like “svn export”)?(转)
    最有价值的信息就是这样的信息:大象是绳子,大象是扇子,大象是柱子…… 这样的信息往往是扭曲的,残缺的,隐晦不明的(转)
    说服他。说不服再按着他的去办(转)
    动手学习TCP:数据传输(转)
    应用程序框架实战十三:DDD分层架构之我见(转)
    UVA11627-Slalom(二分法)
    数据库系统原理及其应用总结---ShinePans
    cocos2d-x 3.0游戏实例学习笔记 《跑酷》第四步--地图循环&amp;主角加入动作
    Android学习四、Android中的Adapter
  • 原文地址:https://www.cnblogs.com/ZERO-/p/8455990.html
Copyright © 2011-2022 走看看