-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeForces-1474A.cpp
More file actions
54 lines (54 loc) · 1.45 KB
/
CodeForces-1474A.cpp
File metadata and controls
54 lines (54 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// Created by abdob on 10/23/2022.
//
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
using namespace std;
int main()
{
fastread();
//freopen("input.txt","r", stdin);
ll t,n;
cin>>t;
while(t--){
string b,s;
cin>>n>>b;
for(ll i=0; i<n; i++){
if(i > 0){
if(b[i] == '1'){
if(b[i-1] == '1' && s[i-1] == '1'){
s += '0';
}
else{
s += '1';
}
}
else{
if(s[i-1] == '0' && b[i-1] == '1'){
s += '0';
}
else if(s[i-1] == '1' && b[i-1] == '0'){
s += '0';
}
else if(s[i-1] == '1' && b[i-1] == '1'){
s += '1';
}
else if(s[i-1] == '0' && b[i-1] == '0'){
s += '1';
}
else{
s += '0';
}
}
}
else{
s += '1';
}
}
cout<<s<<endl;
}
return 0;
}