Submission #1027799

# Submission time Handle Problem Language Result Execution time Memory
1027799 2024-07-19T10:06:02 Z Issa Tiles (BOI24_tiles) C++17
19 / 100
40 ms 27624 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ent "\n"

const int maxn = 1e6 + 100;
const ll INF = (ll)1e18 + 100;
const int inf = 1e9 + 100;
const int MOD = 1e9 + 123;
const int maxl = 26;
const int P = 31;

int n, m;
int a[maxn];
int b[maxn];
int c[1010][1010];

void test(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> a[i] >> b[i];
	}
	for(int i = 1; i <= n; i++){
		int j = i - 1;
		if(!j) j = n;
		if(a[i] == a[j]){
			int l = min(b[i], b[j]);
			int r = b[i] + b[j] - l;
			for(int y = l; y < r; y++){
				c[a[i]][y] ^= 1;
			}
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j <= 1000; j++){
			if(i) c[i][j] ^= c[i-1][j];
		}
	}
	int ans = 0;
	for(int i = 0; i < m; i++){
		int ok = 0;
		for(int j = 0; j <= 1000; j++){
			if(c[i][j]){
				ok = 1;
				if(c[i+1][j] && c[i][j+1] && c[i+1][j+1]){
					c[i][j] = 0;
					c[i+1][j] = 0;
					c[i][j+1] = 0;
					c[i+1][j+1] = 0;
				} else{
					ok = 2;
					break;
				}
			}
		}
		if(ok == 2) break;
		if(ok == 1) continue;
		ans = i + 1;
	}
	cout << ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t; t = 1;
    while(t--) test();
    cout << ent;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4184 KB Output is correct
2 Runtime error 19 ms 24412 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 0 ms 356 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 18 ms 5724 KB Output is correct
6 Correct 19 ms 5724 KB Output is correct
7 Correct 3 ms 4188 KB Output is correct
8 Correct 3 ms 3932 KB Output is correct
9 Correct 3 ms 4188 KB Output is correct
10 Correct 4 ms 4444 KB Output is correct
11 Correct 3 ms 4188 KB Output is correct
12 Correct 3 ms 4188 KB Output is correct
13 Correct 4 ms 4188 KB Output is correct
14 Correct 2 ms 4256 KB Output is correct
15 Correct 2 ms 4188 KB Output is correct
16 Correct 3 ms 4188 KB Output is correct
17 Correct 19 ms 5680 KB Output is correct
18 Correct 19 ms 5724 KB Output is correct
19 Correct 4 ms 4344 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 2 ms 2140 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 0 ms 612 KB Output is correct
24 Correct 3 ms 4188 KB Output is correct
25 Correct 3 ms 3932 KB Output is correct
26 Correct 2 ms 1684 KB Output is correct
27 Correct 3 ms 3932 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 1884 KB Output is correct
31 Correct 1 ms 2016 KB Output is correct
32 Correct 2 ms 3164 KB Output is correct
33 Correct 3 ms 4188 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 3 ms 3164 KB Output is correct
37 Correct 3 ms 3424 KB Output is correct
38 Correct 3 ms 4188 KB Output is correct
39 Correct 2 ms 2912 KB Output is correct
40 Correct 2 ms 4312 KB Output is correct
41 Correct 2 ms 3796 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 472 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 2 ms 3420 KB Output is correct
47 Correct 1 ms 1628 KB Output is correct
48 Correct 4 ms 4188 KB Output is correct
49 Correct 19 ms 7424 KB Output is correct
50 Correct 19 ms 7260 KB Output is correct
51 Correct 20 ms 7260 KB Output is correct
52 Correct 20 ms 7260 KB Output is correct
53 Correct 3 ms 3540 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 4 ms 4420 KB Output is correct
56 Correct 5 ms 4444 KB Output is correct
57 Correct 2 ms 2396 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 2 ms 2908 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 4 ms 4188 KB Output is correct
64 Correct 5 ms 4444 KB Output is correct
65 Correct 3 ms 3676 KB Output is correct
66 Correct 2 ms 4188 KB Output is correct
67 Correct 3 ms 4188 KB Output is correct
68 Correct 2 ms 4188 KB Output is correct
69 Correct 3 ms 4188 KB Output is correct
70 Correct 3 ms 4188 KB Output is correct
71 Correct 3 ms 4444 KB Output is correct
72 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 40 ms 27624 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -