B:
Test instructions: Given a string, and given m digits
For each of the digital AI meanings, flip the AI to the n-ai+1 string again.
A string that requires the output to be flipped after M-times.
The idea is to determine the position of the first character is reversed odd number of times, or even a few times on it, flipped an even number of times represents no flip
The idea is to store the m numbers down and then sort them. For each str[i], 1<=i<strlen (str),
Using Index=upper_bound (a,a+m,i), the return value of Upper_bound (A,a+m,i) is the first element iterator in the returned array that is larger than I, and if not, returns the iterator that points to the last element
So index-a represents the number of digits in array A that are smaller than I.
So if the index-a is odd, then the position I flips the odd number of times, the output STR[N-I+1]
If it is even, the code position I flips an even number of times, output STR[I]
1#include <stdio.h>2#include <string.h>3#include <algorithm>4 using namespacestd;5 Const intN =200000+Ten;6 CharStr[n];7 intA[n];8 BOOLVis[n];9 Ten intMain () One { A intM,i,x,n; -scanf"%s", str+1); -scanf"%d",&m); then = strlen (str+1); - for(i=1; i<=m; ++i) -scanf"%d",&a[i]); -Sort (A +1, a+m+1); + intnn = n/2,*index; - for(i=1; i<=nn; ++i) + { A atindex = Upper_bound (A +1, a+m+1, i); - if((index-a-1)%2==1) - { -printf"%c", str[n-i+1]); -vis[n-i+1] =true; - } in Else -printf"%c", Str[i]); to + } - for(i=nn+1; i<=n; ++i) the { * if(Vis[i]) $printf"%c", str[n-i+1]);Panax Notoginseng Else -printf"%c", Str[i]); the } +Puts""); A}View Code
But watching someone else.
Codeforces round#297 Div2