# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
292331 |
2020-09-06T20:43:06 Z |
VodkaInTheJar |
Game (IOI14_game) |
C++14 |
|
531 ms |
8568 KB |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1503;
const int k = 40;
int cnt[maxn][maxn];
vector <int> adj[maxn];
int n, cnt_buckets;
void initialize(int m)
{
n = m;
cnt_buckets = (n - 1) / k;
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++)
{
if ((i - 1) / k == (j - 1) / k)
adj[i].push_back(j), adj[j].push_back(i);
else
cnt[(i - 1) / k][(j - 1) / k]++, cnt[(j - 1) / k][(i - 1) / k]++;
}
}
int cnt_used = 0;
bool used[maxn];
void dfs1(int ver)
{
used[ver] = true;
cnt_used++;
for (int i = 0; i <= cnt_buckets; i++)
if (!used[i] && cnt[ver][i])
dfs1(i);
}
void dfs2(int ver)
{
used[ver] = true;
cnt_used++;
for (auto i: adj[ver])
if (!used[i])
dfs2(i);
}
int hasEdge(int u, int v)
{
u++;
v++;
if ((u - 1) / k == (v - 1) / k)
{
auto it1 = find(adj[u].begin(), adj[u].end(), v);
auto it2 = find(adj[v].begin(), adj[v].end(), u);
adj[u].erase(it1);
adj[v].erase(it2);
int first = (u - 1) / k * k + 1;
int last = min(n, first + k - 1);
for (int i = first; i <= last; i++)
used[i] = false;
cnt_used = 0;
dfs2(first);
if (cnt_used != last - first + 1)
{
adj[u].push_back(v);
adj[v].push_back(u);
return 1;
}
return 0;
}
else
{
cnt[(u - 1) / k][(v - 1) / k]--;
cnt[(v - 1) / k][(u - 1) / k]--;
if (cnt[(u - 1) / k][(v - 1) / k] >= 1)
return 0;
for (int i = 0; i <= cnt_buckets; i++)
used[i] = false;
cnt_used = 0;
dfs1(0);
if (cnt_used != cnt_buckets + 1)
{
cnt[(u - 1) / k][(v - 1) / k]++;
cnt[(v - 1) / k][(u - 1) / k]++;
return 1;
}
return 0;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
0 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
0 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
416 KB |
Output is correct |
25 |
Correct |
2 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
6 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
3 ms |
384 KB |
Output is correct |
31 |
Correct |
1 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
33 |
Correct |
2 ms |
384 KB |
Output is correct |
34 |
Correct |
4 ms |
384 KB |
Output is correct |
35 |
Correct |
5 ms |
384 KB |
Output is correct |
36 |
Correct |
4 ms |
384 KB |
Output is correct |
37 |
Correct |
4 ms |
384 KB |
Output is correct |
38 |
Correct |
4 ms |
384 KB |
Output is correct |
39 |
Correct |
4 ms |
384 KB |
Output is correct |
40 |
Correct |
6 ms |
384 KB |
Output is correct |
41 |
Correct |
4 ms |
384 KB |
Output is correct |
42 |
Correct |
6 ms |
384 KB |
Output is correct |
43 |
Correct |
4 ms |
384 KB |
Output is correct |
44 |
Correct |
4 ms |
384 KB |
Output is correct |
45 |
Correct |
4 ms |
384 KB |
Output is correct |
46 |
Correct |
5 ms |
384 KB |
Output is correct |
47 |
Correct |
4 ms |
384 KB |
Output is correct |
48 |
Correct |
4 ms |
384 KB |
Output is correct |
49 |
Correct |
4 ms |
384 KB |
Output is correct |
50 |
Correct |
4 ms |
384 KB |
Output is correct |
51 |
Correct |
4 ms |
384 KB |
Output is correct |
52 |
Correct |
4 ms |
384 KB |
Output is correct |
53 |
Correct |
4 ms |
384 KB |
Output is correct |
54 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
0 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
0 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
1 ms |
384 KB |
Output is correct |
32 |
Correct |
1 ms |
384 KB |
Output is correct |
33 |
Correct |
1 ms |
384 KB |
Output is correct |
34 |
Correct |
4 ms |
384 KB |
Output is correct |
35 |
Correct |
4 ms |
384 KB |
Output is correct |
36 |
Correct |
4 ms |
384 KB |
Output is correct |
37 |
Correct |
4 ms |
384 KB |
Output is correct |
38 |
Correct |
4 ms |
384 KB |
Output is correct |
39 |
Correct |
4 ms |
384 KB |
Output is correct |
40 |
Correct |
4 ms |
384 KB |
Output is correct |
41 |
Correct |
4 ms |
384 KB |
Output is correct |
42 |
Correct |
4 ms |
384 KB |
Output is correct |
43 |
Correct |
4 ms |
384 KB |
Output is correct |
44 |
Correct |
3 ms |
384 KB |
Output is correct |
45 |
Correct |
4 ms |
384 KB |
Output is correct |
46 |
Correct |
4 ms |
384 KB |
Output is correct |
47 |
Correct |
4 ms |
384 KB |
Output is correct |
48 |
Correct |
5 ms |
384 KB |
Output is correct |
49 |
Correct |
4 ms |
384 KB |
Output is correct |
50 |
Correct |
4 ms |
384 KB |
Output is correct |
51 |
Correct |
4 ms |
384 KB |
Output is correct |
52 |
Correct |
4 ms |
384 KB |
Output is correct |
53 |
Correct |
4 ms |
384 KB |
Output is correct |
54 |
Correct |
4 ms |
384 KB |
Output is correct |
55 |
Correct |
64 ms |
2168 KB |
Output is correct |
56 |
Correct |
64 ms |
2168 KB |
Output is correct |
57 |
Correct |
63 ms |
2168 KB |
Output is correct |
58 |
Correct |
64 ms |
2168 KB |
Output is correct |
59 |
Correct |
64 ms |
2168 KB |
Output is correct |
60 |
Correct |
64 ms |
2168 KB |
Output is correct |
61 |
Correct |
64 ms |
2168 KB |
Output is correct |
62 |
Correct |
66 ms |
2168 KB |
Output is correct |
63 |
Correct |
65 ms |
2168 KB |
Output is correct |
64 |
Correct |
59 ms |
2188 KB |
Output is correct |
65 |
Correct |
62 ms |
2296 KB |
Output is correct |
66 |
Correct |
64 ms |
2168 KB |
Output is correct |
67 |
Correct |
65 ms |
2296 KB |
Output is correct |
68 |
Correct |
64 ms |
2168 KB |
Output is correct |
69 |
Correct |
64 ms |
2168 KB |
Output is correct |
70 |
Correct |
63 ms |
2168 KB |
Output is correct |
71 |
Correct |
64 ms |
2168 KB |
Output is correct |
72 |
Correct |
64 ms |
2168 KB |
Output is correct |
73 |
Correct |
64 ms |
2168 KB |
Output is correct |
74 |
Correct |
64 ms |
2168 KB |
Output is correct |
75 |
Correct |
64 ms |
2168 KB |
Output is correct |
76 |
Correct |
137 ms |
3448 KB |
Output is correct |
77 |
Correct |
135 ms |
3296 KB |
Output is correct |
78 |
Correct |
139 ms |
3320 KB |
Output is correct |
79 |
Correct |
137 ms |
3320 KB |
Output is correct |
80 |
Correct |
132 ms |
3320 KB |
Output is correct |
81 |
Correct |
136 ms |
3320 KB |
Output is correct |
82 |
Correct |
138 ms |
3320 KB |
Output is correct |
83 |
Correct |
135 ms |
3324 KB |
Output is correct |
84 |
Correct |
135 ms |
3320 KB |
Output is correct |
85 |
Correct |
223 ms |
4728 KB |
Output is correct |
86 |
Correct |
222 ms |
4728 KB |
Output is correct |
87 |
Correct |
221 ms |
4728 KB |
Output is correct |
88 |
Correct |
224 ms |
4728 KB |
Output is correct |
89 |
Correct |
227 ms |
4728 KB |
Output is correct |
90 |
Correct |
226 ms |
4856 KB |
Output is correct |
91 |
Correct |
226 ms |
4856 KB |
Output is correct |
92 |
Correct |
221 ms |
4728 KB |
Output is correct |
93 |
Correct |
224 ms |
4728 KB |
Output is correct |
94 |
Correct |
487 ms |
8440 KB |
Output is correct |
95 |
Correct |
474 ms |
8440 KB |
Output is correct |
96 |
Correct |
475 ms |
8440 KB |
Output is correct |
97 |
Correct |
472 ms |
8568 KB |
Output is correct |
98 |
Correct |
474 ms |
8440 KB |
Output is correct |
99 |
Correct |
531 ms |
8568 KB |
Output is correct |
100 |
Correct |
469 ms |
8440 KB |
Output is correct |