Submission #488102

# Submission time Handle Problem Language Result Execution time Memory
488102 2021-11-17T17:29:06 Z AdamGS Furniture (JOI20_furniture) C++14
5 / 100
5000 ms 24936 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e3+7, INF=1e9+7;
int T[LIM][LIM], dp[LIM][LIM], uzyte[LIM][LIM], ans[LIM*LIM], n, m;
pair<int,int>P[LIM*LIM];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	rep(i, n) rep(j, m) {
		T[i][j]=INF;
		int a;
		cin >> a;
		if(a) T[i][j]=-1;
	}
	int q;
	cin >> q;
	rep(i, q) {
		ans[i]=1;
		int a, b;
		cin >> a >> b; --a; --b;
		T[a][b]=i;
		P[i]={a, b};
	}
	rep(i, n+1) dp[i][0]=-1;
	rep(i, m+1) dp[0][i]=-1;
	dp[0][1]=dp[1][0]=INF;
	while(true) {
		rep(i, n) rep(j, m) {
			dp[i+1][j+1]=min(T[i][j], max(dp[i][j+1], dp[i+1][j]));
		}
		if(dp[n][m]==INF) break;
		ans[dp[n][m]]=0;
		T[P[dp[n][m]].st][P[dp[n][m]].nd]=INF;
	}
	rep(i, q) cout << ans[i] << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 844 KB Output is correct
2 Correct 3 ms 1100 KB Output is correct
3 Correct 5 ms 1104 KB Output is correct
4 Correct 10 ms 1232 KB Output is correct
5 Correct 10 ms 1308 KB Output is correct
6 Correct 12 ms 1216 KB Output is correct
7 Correct 7 ms 1236 KB Output is correct
8 Correct 6 ms 1228 KB Output is correct
9 Correct 7 ms 1232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 844 KB Output is correct
2 Correct 3 ms 1100 KB Output is correct
3 Correct 5 ms 1104 KB Output is correct
4 Correct 10 ms 1232 KB Output is correct
5 Correct 10 ms 1308 KB Output is correct
6 Correct 12 ms 1216 KB Output is correct
7 Correct 7 ms 1236 KB Output is correct
8 Correct 6 ms 1228 KB Output is correct
9 Correct 7 ms 1232 KB Output is correct
10 Correct 94 ms 1360 KB Output is correct
11 Correct 6 ms 848 KB Output is correct
12 Correct 469 ms 16024 KB Output is correct
13 Correct 58 ms 9804 KB Output is correct
14 Execution timed out 5076 ms 24936 KB Time limit exceeded
15 Halted 0 ms 0 KB -