题目大意:
分析:
AC code:
#include
#define inv(n, x) ((n)-(x)+1) #define pii pair
#define X first #define Y second #define pb push_back #define mp make_pair #define clr(a, b) memset(a, b, sizeof a) #define rep(i, a, b) for(int i = (a); i <= (b); ++i) #define per(i, a, b) for(int i = (a); i >= (b); --i) typedef long long LL; typedef double DB; typedef long double LD; using namespace std; void open_init() { #ifndef ONLINE_JUDGE freopen(input.txt, r, stdin); freopen(output.txt, w, stdout); #endif ios::sync_with_stdio(0); } void close_file() { #ifndef ONLINE_JUDGE fclose(stdin); fclose(stdout); #endif } const int MAXN = 4100; int n; char str[MAXN]; bitset
cur, nxt; char src; int s[2], l; inline void add(char c) { s[c==src]++, cur[++l] = c==src; } int main() { open_init(); scanf(%d %c, &n, &src); s[1]++, cur[++l] = 1; puts(Qc);puts(0 0); for(int i = 2, mid = 2; i <= n; ++i, ++mid) { add(getchar()), add(getchar()); bitset
tmp; rep(k, 0, 1) { int ts[2] = {s[0], s[1]}; if(ts[0]&1) tmp[mid] = 0, ts[0]--; else tmp[mid] = 1, ts[1]--; for(int j = 1, tk = k; j < mid; ++j, tk ^= 1) if(!ts[tk]) tmp[j] = tmp[l-j+1] = tk^1, ts[tk^1] -= 2; else tmp[j] = tmp[l-j+1] = tk, ts[tk] -= 2; if(!k || (tmp^cur).count() < (nxt^cur).count()) nxt = tmp; } vector
p[2]; rep(j, 1, l) if(nxt[j] != cur[j]) p[cur[j]].pb(j); rep(j, p[0].size()+1, 2) puts(0 0); rep(j, 0, (int)p[0].size()-1) printf(%d %d , p[0][j], p[1][j]); cur = nxt; } close_file(); return 0; }
?