# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1027803 |
2024-07-19T10:09:09 Z |
Issa |
Tiles (BOI24_tiles) |
C++17 |
|
43 ms |
7432 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;
int mx = 0;
for(int i = 1; i <= n; i++){
cin >> a[i] >> b[i];
mx = max(mx, b[i]);
}
if(m > 1000 || mx > 1000){
vector<int> v;
for(int i = 2; i <= n; i++){
while(v.size() > 1){
int k = v[v.size()-2], j = v.back();
if(a[k] == a[j] && a[j] == a[i]) v.pop_back();
else if(b[k] == b[j] && b[j] == b[i]) v.pop_back();
else break;
} v.push_back(i);
}
int ans = 0;
for(int i: v){
if((b[i] & 1 )|| !b[i]) break;
ans = a[i] - (a[i] & 1);
if(a[i] & 1) break;
}
cout << ans;
} else{
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 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
3932 KB |
Output is correct |
4 |
Correct |
1 ms |
1628 KB |
Output is correct |
5 |
Correct |
3 ms |
3928 KB |
Output is correct |
6 |
Correct |
0 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
352 KB |
Output is correct |
8 |
Correct |
1 ms |
1884 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
352 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
3932 KB |
Output is correct |
4 |
Correct |
1 ms |
1628 KB |
Output is correct |
5 |
Correct |
3 ms |
3928 KB |
Output is correct |
6 |
Correct |
0 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
352 KB |
Output is correct |
8 |
Correct |
1 ms |
1884 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4184 KB |
Output is correct |
2 |
Correct |
5 ms |
1112 KB |
Output is correct |
3 |
Correct |
26 ms |
3172 KB |
Output is correct |
4 |
Correct |
19 ms |
1756 KB |
Output is correct |
5 |
Correct |
14 ms |
1848 KB |
Output is correct |
6 |
Correct |
5 ms |
4184 KB |
Output is correct |
7 |
Correct |
3 ms |
4184 KB |
Output is correct |
8 |
Correct |
27 ms |
3036 KB |
Output is correct |
9 |
Correct |
16 ms |
1968 KB |
Output is correct |
10 |
Correct |
27 ms |
3036 KB |
Output is correct |
11 |
Correct |
13 ms |
1760 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
29 ms |
3752 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
356 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
4188 KB |
Output is correct |
5 |
Correct |
20 ms |
5816 KB |
Output is correct |
6 |
Correct |
19 ms |
5832 KB |
Output is correct |
7 |
Correct |
4 ms |
4404 KB |
Output is correct |
8 |
Correct |
3 ms |
3928 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 |
3 ms |
4188 KB |
Output is correct |
14 |
Correct |
2 ms |
4188 KB |
Output is correct |
15 |
Correct |
2 ms |
4188 KB |
Output is correct |
16 |
Correct |
3 ms |
4188 KB |
Output is correct |
17 |
Correct |
18 ms |
5880 KB |
Output is correct |
18 |
Correct |
18 ms |
5720 KB |
Output is correct |
19 |
Correct |
4 ms |
4444 KB |
Output is correct |
20 |
Correct |
2 ms |
2652 KB |
Output is correct |
21 |
Correct |
2 ms |
2140 KB |
Output is correct |
22 |
Correct |
2 ms |
2648 KB |
Output is correct |
23 |
Correct |
1 ms |
604 KB |
Output is correct |
24 |
Correct |
3 ms |
4188 KB |
Output is correct |
25 |
Correct |
3 ms |
3928 KB |
Output is correct |
26 |
Correct |
1 ms |
1628 KB |
Output is correct |
27 |
Correct |
3 ms |
3932 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
1884 KB |
Output is correct |
31 |
Correct |
1 ms |
1884 KB |
Output is correct |
32 |
Correct |
2 ms |
3164 KB |
Output is correct |
33 |
Correct |
3 ms |
4424 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
2 ms |
3164 KB |
Output is correct |
37 |
Correct |
2 ms |
3420 KB |
Output is correct |
38 |
Correct |
3 ms |
4284 KB |
Output is correct |
39 |
Correct |
2 ms |
2908 KB |
Output is correct |
40 |
Correct |
3 ms |
4188 KB |
Output is correct |
41 |
Correct |
2 ms |
3932 KB |
Output is correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
2 ms |
3420 KB |
Output is correct |
47 |
Correct |
2 ms |
1628 KB |
Output is correct |
48 |
Correct |
3 ms |
4204 KB |
Output is correct |
49 |
Correct |
20 ms |
7432 KB |
Output is correct |
50 |
Correct |
21 ms |
7424 KB |
Output is correct |
51 |
Correct |
20 ms |
7256 KB |
Output is correct |
52 |
Correct |
20 ms |
7260 KB |
Output is correct |
53 |
Correct |
3 ms |
3676 KB |
Output is correct |
54 |
Correct |
1 ms |
348 KB |
Output is correct |
55 |
Correct |
4 ms |
4444 KB |
Output is correct |
56 |
Correct |
4 ms |
4484 KB |
Output is correct |
57 |
Correct |
2 ms |
2272 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 |
352 KB |
Output is correct |
61 |
Correct |
0 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 |
4 ms |
4444 KB |
Output is correct |
65 |
Correct |
3 ms |
3676 KB |
Output is correct |
66 |
Correct |
3 ms |
4308 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 |
4184 KB |
Output is correct |
71 |
Correct |
3 ms |
4444 KB |
Output is correct |
72 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
14 ms |
3844 KB |
Output is correct |
3 |
Correct |
17 ms |
3796 KB |
Output is correct |
4 |
Correct |
21 ms |
7256 KB |
Output is correct |
5 |
Correct |
21 ms |
7152 KB |
Output is correct |
6 |
Correct |
3 ms |
4188 KB |
Output is correct |
7 |
Correct |
3 ms |
4440 KB |
Output is correct |
8 |
Incorrect |
43 ms |
6920 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
6612 KB |
Output is correct |
2 |
Correct |
14 ms |
3796 KB |
Output is correct |
3 |
Correct |
3 ms |
2652 KB |
Output is correct |
4 |
Incorrect |
28 ms |
6988 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
352 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
3932 KB |
Output is correct |
4 |
Correct |
1 ms |
1628 KB |
Output is correct |
5 |
Correct |
3 ms |
3928 KB |
Output is correct |
6 |
Correct |
0 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
352 KB |
Output is correct |
8 |
Correct |
1 ms |
1884 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |