Codeforces Round #696 (Div. 2) A. Puzzle From the Fut
Codeforces Round #696 (Div. 2) A. Puzzle From the Future
[原题链接](Problem - A - Codeforces)
AC代码:
#include<bits/stdc++.h>
using namespace std;
#define io ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const int N = 1e6 + 1000;
int a[N], b[N];
int t, n;
int main(){
io;
cin >> t;
while(t--){
string s;
cin >> n >> s;
for(int i = 0; i < s.length(); i++){
if(s[i] == '0') a[i] = 0;
else a[i] = 1;
b[i] = 0;
}
b[0] = 1;
for(int i = 1; i < n; i++){
if(a[i] + 1 == a[i - 1] + b[i - 1]) b[i] = 0;
else if(a[i] + 1 != a[i - 1] + b[i - 1]) b[i] = 1;
}
for(int i = 0; i < n; i++) cout << b[i];
cout << endl;
}
return 0;
}