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 }
  • 相关阅读:
    Codeforces 787D. Legacy 线段树优化建图+最短路
    Codeforces 1051E. Vasya and Big Integers
    BZOJ3261 最大异或和
    BZOJ3531 SDOI2014 旅行
    洛谷P2468 SDOI 2010 粟粟的书架
    2018 ICPC 焦作网络赛 E.Jiu Yuan Wants to Eat
    HDU6280 From Tree to Graph
    HDU5985 Lucky Coins 概率dp
    (HDU)1334 -- Perfect Cubes (完美立方)
    (HDU)1330 -- Deck (覆盖物)
  • 原文地址:https://www.cnblogs.com/ZERO-/p/8455990.html
Copyright © 2011-2022 走看看