Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Python profiler results by nhatduy ( 3 years ago )
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q;
cin >> n >> q;
char a[3][n + 3];
for(int i = 1; i <= 2; ++i){
for(int j = 1; j <= n; ++j){
a[i][j] = '.';
}
}
a[1][1] = 'F';
a[2][n] = 'V';
int cnt = 0;
while(q--){
int y, x;
cin >> y >> x;
if(a[y][x] == '.'){
a[y][x] = 'x';
if(y == 1){
if(x - 1 >= 1 && a[2][x - 1] == 'x'){
cnt++;
}
if(a[2][x] == 'x'){
cnt++;
}
if(x + 1 <= n && a[2][x + 1] == 'x'){
cnt++;
}
}
else{
if(x - 1 >= 1 && a[1][x - 1] == 'x'){
cnt++;
}
if(a[1][x] == 'x'){
cnt++;
}
if(x + 1 <= n && a[1][x + 1] == 'x'){
cnt++;
}
}
}
else if(a[y][x] == 'x'){
a[y][x] = '.';
if(y == 1){
if(x - 1 >= 1 && a[2][x - 1] == 'x'){
cnt--;
}
if(a[2][x] == 'x'){
cnt--;
}
if(x + 1 <= n && a[2][x + 1] == 'x'){
cnt--;
}
}
else{
if(x - 1 >= 1 && a[1][x - 1] == 'x'){
cnt--;
}
if(a[1][x] == 'x'){
cnt--;
}
if(x + 1 <= n && a[1][x + 1] == 'x'){
cnt--;
}
}
}
if(cnt != 0){
cout << "NO\n";
}
else{
cout << "YES\n";
}
}
return 0;
}
Revise this Paste
Parent: 125033