# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
250227 |
2020-07-17T08:55:48 Z |
srvlt |
Simurgh (IOI17_simurgh) |
C++14 |
|
192 ms |
6400 KB |
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define SZ(x) (int)(x).size()
const int n0 = 243, m0 = 29000;
int N, M, used[n0], ch[m0], par[n0], sp[m0], same[m0];
int in[n0], out[n0], T, common;
vector <int> g[n0], V, U, query;
void dfs(int v) {
used[v] = 1;
in[v] = ++T;
for (int i : g[v]) {
int to = V[i] ^ U[i] ^ v;
if (used[to]) continue;
par[to] = i;
query.pb(i);
sp[i] = 1;
dfs(to);
}
out[v] = T;
}
bool upper(int v, int u) {
return in[v] <= in[u] && out[u] <= out[v];
}
void add(int x) {
query.pb(x);
}
void del(int x) {
for (int i = 0; i < SZ(query); i++) {
if (query[i] == x) {
query.erase(query.begin() + i);
break;
}
}
}
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
memset(& ch, -1, sizeof(ch));
N = n, M = u.size(), V = v, U = u;
for (int i = 0; i < M; i++)
g[v[i]].pb(i), g[u[i]].pb(i);
dfs(0);
vector <int> path;
common = count_common_roads(query);
for (int i = 0; i < M; i++) {
if (sp[i]) continue;
int a = v[i], b = u[i];
if (upper(b, a)) swap(a, b);
path.clear();
while (b != a) {
path.pb(par[b]);
b = v[par[b]] ^ u[par[b]] ^ b;
}
add(i);
for (int j : path) {
if (ch[i] != -1 && ch[j] != -1) continue;
del(j);
int x = count_common_roads(query);
if (x == common) {
if (ch[j] != -1) ch[i] = ch[j];
same[j] = 1;
} else {
if (x == common - 1) {
ch[i] = 0;
ch[j] = 1;
}
if (x == common + 1) {
ch[i] = 1;
ch[j] = 0;
}
}
add(j);
}
if (ch[i] == -1) ch[i] = 0;
del(i);
for (int j : path) {
if (same[j]) ch[j] = ch[i];
same[j] = 0;
}
}
vector <int> res;
for (int i = 0; i < M; i++) {
if (ch[i] == -1) ch[i] = 1;
if (ch[i] == 1) res.pb(i);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
correct |
2 |
Correct |
0 ms |
416 KB |
correct |
3 |
Correct |
1 ms |
384 KB |
correct |
4 |
Correct |
0 ms |
384 KB |
correct |
5 |
Correct |
1 ms |
384 KB |
correct |
6 |
Correct |
0 ms |
384 KB |
correct |
7 |
Correct |
0 ms |
384 KB |
correct |
8 |
Correct |
0 ms |
384 KB |
correct |
9 |
Correct |
1 ms |
384 KB |
correct |
10 |
Correct |
0 ms |
384 KB |
correct |
11 |
Correct |
1 ms |
384 KB |
correct |
12 |
Correct |
0 ms |
384 KB |
correct |
13 |
Correct |
1 ms |
384 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
correct |
2 |
Correct |
0 ms |
416 KB |
correct |
3 |
Correct |
1 ms |
384 KB |
correct |
4 |
Correct |
0 ms |
384 KB |
correct |
5 |
Correct |
1 ms |
384 KB |
correct |
6 |
Correct |
0 ms |
384 KB |
correct |
7 |
Correct |
0 ms |
384 KB |
correct |
8 |
Correct |
0 ms |
384 KB |
correct |
9 |
Correct |
1 ms |
384 KB |
correct |
10 |
Correct |
0 ms |
384 KB |
correct |
11 |
Correct |
1 ms |
384 KB |
correct |
12 |
Correct |
0 ms |
384 KB |
correct |
13 |
Correct |
1 ms |
384 KB |
correct |
14 |
Correct |
3 ms |
512 KB |
correct |
15 |
Correct |
3 ms |
512 KB |
correct |
16 |
Correct |
3 ms |
512 KB |
correct |
17 |
Correct |
2 ms |
512 KB |
correct |
18 |
Correct |
1 ms |
512 KB |
correct |
19 |
Correct |
2 ms |
512 KB |
correct |
20 |
Correct |
2 ms |
512 KB |
correct |
21 |
Correct |
2 ms |
512 KB |
correct |
22 |
Correct |
2 ms |
512 KB |
correct |
23 |
Correct |
2 ms |
512 KB |
correct |
24 |
Correct |
2 ms |
512 KB |
correct |
25 |
Correct |
1 ms |
384 KB |
correct |
26 |
Correct |
1 ms |
512 KB |
correct |
27 |
Correct |
2 ms |
512 KB |
correct |
28 |
Correct |
1 ms |
512 KB |
correct |
29 |
Correct |
1 ms |
512 KB |
correct |
30 |
Correct |
2 ms |
512 KB |
correct |
31 |
Correct |
2 ms |
512 KB |
correct |
32 |
Correct |
2 ms |
512 KB |
correct |
33 |
Correct |
2 ms |
512 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
correct |
2 |
Correct |
0 ms |
416 KB |
correct |
3 |
Correct |
1 ms |
384 KB |
correct |
4 |
Correct |
0 ms |
384 KB |
correct |
5 |
Correct |
1 ms |
384 KB |
correct |
6 |
Correct |
0 ms |
384 KB |
correct |
7 |
Correct |
0 ms |
384 KB |
correct |
8 |
Correct |
0 ms |
384 KB |
correct |
9 |
Correct |
1 ms |
384 KB |
correct |
10 |
Correct |
0 ms |
384 KB |
correct |
11 |
Correct |
1 ms |
384 KB |
correct |
12 |
Correct |
0 ms |
384 KB |
correct |
13 |
Correct |
1 ms |
384 KB |
correct |
14 |
Correct |
3 ms |
512 KB |
correct |
15 |
Correct |
3 ms |
512 KB |
correct |
16 |
Correct |
3 ms |
512 KB |
correct |
17 |
Correct |
2 ms |
512 KB |
correct |
18 |
Correct |
1 ms |
512 KB |
correct |
19 |
Correct |
2 ms |
512 KB |
correct |
20 |
Correct |
2 ms |
512 KB |
correct |
21 |
Correct |
2 ms |
512 KB |
correct |
22 |
Correct |
2 ms |
512 KB |
correct |
23 |
Correct |
2 ms |
512 KB |
correct |
24 |
Correct |
2 ms |
512 KB |
correct |
25 |
Correct |
1 ms |
384 KB |
correct |
26 |
Correct |
1 ms |
512 KB |
correct |
27 |
Correct |
2 ms |
512 KB |
correct |
28 |
Correct |
1 ms |
512 KB |
correct |
29 |
Correct |
1 ms |
512 KB |
correct |
30 |
Correct |
2 ms |
512 KB |
correct |
31 |
Correct |
2 ms |
512 KB |
correct |
32 |
Correct |
2 ms |
512 KB |
correct |
33 |
Correct |
2 ms |
512 KB |
correct |
34 |
Correct |
192 ms |
1408 KB |
correct |
35 |
Correct |
188 ms |
1408 KB |
correct |
36 |
Correct |
127 ms |
1400 KB |
correct |
37 |
Correct |
8 ms |
512 KB |
correct |
38 |
Correct |
190 ms |
1408 KB |
correct |
39 |
Correct |
162 ms |
1408 KB |
correct |
40 |
Correct |
126 ms |
1280 KB |
correct |
41 |
Correct |
188 ms |
1516 KB |
correct |
42 |
Correct |
191 ms |
1408 KB |
correct |
43 |
Correct |
96 ms |
1144 KB |
correct |
44 |
Correct |
76 ms |
896 KB |
correct |
45 |
Correct |
91 ms |
1024 KB |
correct |
46 |
Correct |
68 ms |
1016 KB |
correct |
47 |
Correct |
28 ms |
640 KB |
correct |
48 |
Correct |
2 ms |
512 KB |
correct |
49 |
Correct |
8 ms |
512 KB |
correct |
50 |
Correct |
29 ms |
760 KB |
correct |
51 |
Correct |
89 ms |
1024 KB |
correct |
52 |
Correct |
79 ms |
896 KB |
correct |
53 |
Correct |
65 ms |
896 KB |
correct |
54 |
Correct |
99 ms |
1024 KB |
correct |
55 |
Correct |
94 ms |
1144 KB |
correct |
56 |
Correct |
95 ms |
1024 KB |
correct |
57 |
Correct |
96 ms |
1028 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
correct |
2 |
Correct |
0 ms |
384 KB |
correct |
3 |
Runtime error |
28 ms |
6400 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
correct |
2 |
Correct |
0 ms |
416 KB |
correct |
3 |
Correct |
1 ms |
384 KB |
correct |
4 |
Correct |
0 ms |
384 KB |
correct |
5 |
Correct |
1 ms |
384 KB |
correct |
6 |
Correct |
0 ms |
384 KB |
correct |
7 |
Correct |
0 ms |
384 KB |
correct |
8 |
Correct |
0 ms |
384 KB |
correct |
9 |
Correct |
1 ms |
384 KB |
correct |
10 |
Correct |
0 ms |
384 KB |
correct |
11 |
Correct |
1 ms |
384 KB |
correct |
12 |
Correct |
0 ms |
384 KB |
correct |
13 |
Correct |
1 ms |
384 KB |
correct |
14 |
Correct |
3 ms |
512 KB |
correct |
15 |
Correct |
3 ms |
512 KB |
correct |
16 |
Correct |
3 ms |
512 KB |
correct |
17 |
Correct |
2 ms |
512 KB |
correct |
18 |
Correct |
1 ms |
512 KB |
correct |
19 |
Correct |
2 ms |
512 KB |
correct |
20 |
Correct |
2 ms |
512 KB |
correct |
21 |
Correct |
2 ms |
512 KB |
correct |
22 |
Correct |
2 ms |
512 KB |
correct |
23 |
Correct |
2 ms |
512 KB |
correct |
24 |
Correct |
2 ms |
512 KB |
correct |
25 |
Correct |
1 ms |
384 KB |
correct |
26 |
Correct |
1 ms |
512 KB |
correct |
27 |
Correct |
2 ms |
512 KB |
correct |
28 |
Correct |
1 ms |
512 KB |
correct |
29 |
Correct |
1 ms |
512 KB |
correct |
30 |
Correct |
2 ms |
512 KB |
correct |
31 |
Correct |
2 ms |
512 KB |
correct |
32 |
Correct |
2 ms |
512 KB |
correct |
33 |
Correct |
2 ms |
512 KB |
correct |
34 |
Correct |
192 ms |
1408 KB |
correct |
35 |
Correct |
188 ms |
1408 KB |
correct |
36 |
Correct |
127 ms |
1400 KB |
correct |
37 |
Correct |
8 ms |
512 KB |
correct |
38 |
Correct |
190 ms |
1408 KB |
correct |
39 |
Correct |
162 ms |
1408 KB |
correct |
40 |
Correct |
126 ms |
1280 KB |
correct |
41 |
Correct |
188 ms |
1516 KB |
correct |
42 |
Correct |
191 ms |
1408 KB |
correct |
43 |
Correct |
96 ms |
1144 KB |
correct |
44 |
Correct |
76 ms |
896 KB |
correct |
45 |
Correct |
91 ms |
1024 KB |
correct |
46 |
Correct |
68 ms |
1016 KB |
correct |
47 |
Correct |
28 ms |
640 KB |
correct |
48 |
Correct |
2 ms |
512 KB |
correct |
49 |
Correct |
8 ms |
512 KB |
correct |
50 |
Correct |
29 ms |
760 KB |
correct |
51 |
Correct |
89 ms |
1024 KB |
correct |
52 |
Correct |
79 ms |
896 KB |
correct |
53 |
Correct |
65 ms |
896 KB |
correct |
54 |
Correct |
99 ms |
1024 KB |
correct |
55 |
Correct |
94 ms |
1144 KB |
correct |
56 |
Correct |
95 ms |
1024 KB |
correct |
57 |
Correct |
96 ms |
1028 KB |
correct |
58 |
Correct |
0 ms |
384 KB |
correct |
59 |
Correct |
0 ms |
384 KB |
correct |
60 |
Runtime error |
28 ms |
6400 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
61 |
Halted |
0 ms |
0 KB |
- |