# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1079193 |
2024-08-28T11:51:42 Z |
raphaelp |
Tiles (BOI24_tiles) |
C++14 |
|
156 ms |
19716 KB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N, M;
cin >> N >> M;
vector<vector<int>> Tab;
vector<int> X(N), Y(N);
for (int i = 0; i < N; i++)
{
cin >> X[i] >> Y[i];
}
for (int i = 0; i < N; i++)
{
if (X[(i + 1) % N] == X[i])
{
if (Y[i] < Y[(i + 1) % N])
Tab.push_back({X[i], min(Y[i], Y[(i + 1) % N]), max(Y[i], Y[(i + 1) % N]) - 1, 1});
else
Tab.push_back({X[i], min(Y[i], Y[(i + 1) % N]), max(Y[i], Y[(i + 1) % N]) - 1, -1});
}
}
sort(Tab.begin(), Tab.end());
if (Tab[0][3] == -1)
for (int i = 0; i < Tab.size(); i++)
Tab[i][3] = 0 - Tab[i][3];
int last = -1;
int impair = 0;
vector<int> mod12(2);
int maxx = 0;
set<vector<int>> S;
for (int i = 0; i < Tab.size(); i++)
{
if (Tab[i][0] != last || i == Tab[i].size() - 1)
{
last = Tab[i][0];
if (impair)
break;
if (mod12[0] == 0 || mod12[1] == 0)
{
int par = ((mod12[1]) ? 1 : 0);
maxx = ((Tab[i][0] % 2 == par) ? Tab[i][0] : (Tab[i][0] - 1));
}
}
if (Tab[i][3] == 1)
{
auto pos = S.lower_bound({Tab[i][1]});
if (pos != S.end() && (*pos)[0] == Tab[i][2] + 1 && (*pos)[2] == Tab[i][0] % 2)
{
Tab[i][2] = (*pos)[1];
if (((*pos)[1] - (*pos)[0] + 1) % 2 == 1)
impair--;
mod12[(*pos)[2]]--;
pos = S.erase(pos);
}
if (pos != S.begin())
{
pos--;
if ((*pos)[1] == Tab[i][1] - 1 && (*pos)[2] == Tab[i][0] % 2)
{
Tab[i][1] = (*pos)[0];
if (((*pos)[1] - (*pos)[0] + 1) % 2 == 1)
impair--;
mod12[(*pos)[2]]--;
S.erase(pos);
}
}
if ((Tab[i][2] - Tab[i][1] + 1) % 2 == 1)
impair++;
mod12[Tab[i][0] % 2]++;
S.insert({Tab[i][1], Tab[i][2], Tab[i][0] % 2});
}
else
{
auto pos = S.upper_bound({Tab[i][2]});
pos--;
if (Tab[i][0] % 2 != (*pos)[2])
break;
if (Tab[i][1] < (*pos)[0])
break;
int left = (*pos)[0], right = Tab[i][1] - 1;
if (right >= left)
{
mod12[(*pos)[2]]++;
if ((right - left) % 2 == 0)
impair++;
S.insert({left, right, (*pos)[2]});
}
left = Tab[i][2] + 1, right = (*pos)[1];
if (right >= left)
{
mod12[(*pos)[2]]++;
if ((right - left) % 2 == 0)
impair++;
S.insert({left, right, (*pos)[2]});
}
mod12[(*pos)[2]]--;
if (((*pos)[1] - (*pos)[0]) % 2 == 0)
impair--;
S.erase(pos);
}
if (Tab[i][0] != last || i == Tab[i].size() - 1)
{
last = Tab[i][0];
if (impair)
break;
if (mod12[0] == 0 || mod12[1] == 0)
{
int par = ((mod12[1]) ? 1 : 0);
maxx = ((Tab[i][0] % 2 == par) ? Tab[i][0] : (Tab[i][0] - 1));
}
}
}
cout << maxx;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:25:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for (int i = 0; i < Tab.size(); i++)
| ~~^~~~~~~~~~~~
Main.cpp:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int i = 0; i < Tab.size(); i++)
| ~~^~~~~~~~~~~~
Main.cpp:34:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | if (Tab[i][0] != last || i == Tab[i].size() - 1)
| ~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:102:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
102 | if (Tab[i][0] != last || i == Tab[i].size() - 1)
| ~~^~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
436 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
436 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 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 |
600 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 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 |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
352 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
72 ms |
5648 KB |
Output is correct |
3 |
Correct |
62 ms |
5644 KB |
Output is correct |
4 |
Correct |
73 ms |
8936 KB |
Output is correct |
5 |
Correct |
78 ms |
8964 KB |
Output is correct |
6 |
Correct |
1 ms |
352 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
111 ms |
11108 KB |
Output is correct |
9 |
Correct |
111 ms |
11112 KB |
Output is correct |
10 |
Correct |
132 ms |
11012 KB |
Output is correct |
11 |
Correct |
125 ms |
11264 KB |
Output is correct |
12 |
Correct |
125 ms |
12632 KB |
Output is correct |
13 |
Correct |
137 ms |
13336 KB |
Output is correct |
14 |
Correct |
120 ms |
11268 KB |
Output is correct |
15 |
Correct |
111 ms |
11008 KB |
Output is correct |
16 |
Correct |
116 ms |
11252 KB |
Output is correct |
17 |
Correct |
127 ms |
11520 KB |
Output is correct |
18 |
Correct |
156 ms |
13568 KB |
Output is correct |
19 |
Correct |
134 ms |
11268 KB |
Output is correct |
20 |
Correct |
117 ms |
11368 KB |
Output is correct |
21 |
Correct |
124 ms |
10856 KB |
Output is correct |
22 |
Correct |
129 ms |
11256 KB |
Output is correct |
23 |
Correct |
119 ms |
15608 KB |
Output is correct |
24 |
Correct |
120 ms |
15368 KB |
Output is correct |
25 |
Correct |
140 ms |
15584 KB |
Output is correct |
26 |
Correct |
137 ms |
19200 KB |
Output is correct |
27 |
Correct |
119 ms |
19168 KB |
Output is correct |
28 |
Correct |
133 ms |
19716 KB |
Output is correct |
29 |
Correct |
135 ms |
11264 KB |
Output is correct |
30 |
Correct |
135 ms |
11268 KB |
Output is correct |
31 |
Correct |
120 ms |
10988 KB |
Output is correct |
32 |
Correct |
138 ms |
11268 KB |
Output is correct |
33 |
Correct |
113 ms |
11264 KB |
Output is correct |
34 |
Correct |
53 ms |
5384 KB |
Output is correct |
35 |
Correct |
0 ms |
344 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
372 KB |
Output is correct |
38 |
Correct |
0 ms |
348 KB |
Output is correct |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
1 ms |
348 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
1 ms |
348 KB |
Output is correct |
47 |
Correct |
1 ms |
348 KB |
Output is correct |
48 |
Correct |
1 ms |
348 KB |
Output is correct |
49 |
Correct |
154 ms |
13560 KB |
Output is correct |
50 |
Correct |
0 ms |
344 KB |
Output is correct |
51 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
52 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
120 ms |
10952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
436 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 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 |
600 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 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 |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
33 |
Halted |
0 ms |
0 KB |
- |