Educational Codeforces Round 94 (Rated for Div. 2) A. String Similarity (构造水题)

-
题意:给你一个长度为\(2*n-1\)的字符串\(s\),让你构造一个长度为\(n\)的字符串,使得构造的字符串中有相同位置的字符等于\(s[1..n],s[2..n+1],...,s[n,2n-1]\)中的位置上的字符.
-
题解:不难发现,\(s\)中的奇数位字符就是我们要的答案.
-
代码:
int t; int n; char s[N]; int main() { //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); t=read(); while(t--){ n=read(); scanf("%s",s+1); for(int i=1;i<=2*n-1;++i){ if(i%2==1) printf("%c",s[i]); } puts(""); } return 0; }
𝓐𝓬𝓱𝓲𝓮𝓿𝓮𝓶𝓮𝓷𝓽 𝓹𝓻𝓸𝓿𝓲𝓭𝓮𝓼 𝓽𝓱𝓮 𝓸𝓷𝓵𝔂 𝓻𝓮𝓪𝓵
𝓹𝓵𝓮𝓪𝓼𝓾𝓻𝓮 𝓲𝓷 𝓵𝓲𝓯𝓮

浙公网安备 33010602011771号