#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;
int czy[N][N], da[N][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++){
for(int j=1; j<=m; j++){
int x;
cin>>czy[i][j];
}
}
da[n][m+1]=1;
int q;
cin>>q;
while(q--){
int x, y;
cin>>x>>y;
czy[x][y]=1;
for(int i=n; i>0; i--){
for(int j=m; j>0; j--){
da[i][j]=(da[i+1][j]|da[i][j+1])&(!czy[i][j]);
}
}
if(da[1][1]){
cout<<1<<"\n";
}
else{
cout<<0<<"\n";
czy[x][y]=0;
}
}
}
Compilation message
furniture.cpp: In function 'int main()':
furniture.cpp:31:8: warning: unused variable 'x' [-Wunused-variable]
31 | int x;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
852 KB |
Output is correct |
2 |
Correct |
50 ms |
980 KB |
Output is correct |
3 |
Correct |
95 ms |
980 KB |
Output is correct |
4 |
Correct |
215 ms |
1124 KB |
Output is correct |
5 |
Correct |
238 ms |
1168 KB |
Output is correct |
6 |
Correct |
298 ms |
1180 KB |
Output is correct |
7 |
Correct |
332 ms |
1184 KB |
Output is correct |
8 |
Correct |
358 ms |
1184 KB |
Output is correct |
9 |
Correct |
316 ms |
1312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
852 KB |
Output is correct |
2 |
Correct |
50 ms |
980 KB |
Output is correct |
3 |
Correct |
95 ms |
980 KB |
Output is correct |
4 |
Correct |
215 ms |
1124 KB |
Output is correct |
5 |
Correct |
238 ms |
1168 KB |
Output is correct |
6 |
Correct |
298 ms |
1180 KB |
Output is correct |
7 |
Correct |
332 ms |
1184 KB |
Output is correct |
8 |
Correct |
358 ms |
1184 KB |
Output is correct |
9 |
Correct |
316 ms |
1312 KB |
Output is correct |
10 |
Correct |
3993 ms |
1340 KB |
Output is correct |
11 |
Correct |
187 ms |
756 KB |
Output is correct |
12 |
Execution timed out |
5061 ms |
10068 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |