#include<bits/stdc++.h>
#define st first
#define nd second
#define eb emplace_back
#define pb push_back
#define pp pop_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
void debug(){cerr<<"\n";}
template<typename H, typename... T>
void debug(H h, T... t){cerr<<h;if(sizeof...(t))cerr<<", ";debug(t...);};
#define deb(x...) cerr<<#x<<" = ";debug(x);
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=1e3+5, INF=1e9+5;
set<int> S[N], S2[N];
int dp[N], dp2[N];
int main(){
//ios_base::sync_with_stdio(0);cin.tie(0);
int n, m;
cin>>n>>m;
for(int i=1; i<=n; i++){
S[i].insert(m+1);
if(i!=1)S[i].insert(0);
S2[i].insert(-1);
for(int j=1; j<=m; j++){
int x;
cin>>x;
if(x)S[i].insert(j);
else S2[i].insert(j);
}
}
dp[0]=1;
int q;
cin>>q;
while(q--){
/*for(int i=1; i<=n; i++){
deb(dp[i], dp2[i]);
}*/
int x, y;
cin>>x>>y;
S[x].insert(y);
S2[x].erase(y);
dp[0]=1;
for(int i=1; i<=n; i++){
auto it=S2[i].lower_bound(*S[i].lower_bound(dp[i-1]-1));
dp[i]=*(--it)+1;
//deb(dp[i]);
}
if(dp[n]==m+1){
cout<<1<<"\n";
}
else{
cout<<0<<"\n";
S[x].erase(y);
S2[x].insert(y);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
596 KB |
Output is correct |
2 |
Incorrect |
16 ms |
648 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
596 KB |
Output is correct |
2 |
Incorrect |
16 ms |
648 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |