占坑,明天写,想把D补出来一起写。2/20/2018 11:17:00 PM
----------------------------------------------------------我是分割线-------------------------------------------------------
我来了,本来打算D题写到一起的,但是有新的东西要写,D就单独写一篇,这里写A,B,C;
开启智障模式:(看我咸鱼突刺的厉害( • ̀ω•́ )✧) 2/21/2018 10:46:00 PM
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.
First line contains a string A (1 ≤ |A| ≤ 103) consisting of lowercase Latin letters, where |A| is a length of A.
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.
aba
aba
ab
aabaa
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 }