# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1060998 |
2024-08-16T05:22:29 Z |
onbert |
Simurgh (IOI17_simurgh) |
C++17 |
|
88 ms |
3672 KB |
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 505;
vector<pair<int,int>> adj[maxn];
int vis[maxn], cnt;
vector<int> used;
void dfs(int u) {
vis[u] = cnt;
for (auto [v, id]:adj[u]) if (!vis[v]) {
used.push_back(id);
dfs(v);
}
}
vector<int> find_roads(int n, vector<int> U, vector<int> V) {
for (int i=0;i<U.size();i++) {
adj[U[i]].push_back({V[i], i}), adj[V[i]].push_back({U[i], i});
}
vector<int> golden;
int ans[U.size()];
for (int i=0;i<U.size();i++) ans[i] = -1;
for (int i=0;i<n;i++) {
for (int j=0;j<n;j++) vis[j] = 0;
vis[i] = -1;
cnt = 0;
used.clear();
vector<vector<int>> vec = {{}};
bool have = false;
for (auto [v, id]:adj[i]) {
if (ans[id]==-1) have = true;
if (vis[v]) vec[vis[v]].push_back(id);
else {
cnt++, vec.push_back({id});
dfs(v);
}
}
if (!have) continue;
for (int j=1;j<=cnt;j++) {
vector<int> thing = used;
for (int k=1;k<=cnt;k++) if (j!=k) thing.push_back(vec[k][0]);
vector<pair<int,int>> ret;
int mx = -1;
for (int v:vec[j]) {
thing.push_back(v);
if (ans[v]==-1) {
// cout << v << " " << ans[v] << endl;
// for (int X:thing) cout << X << " "; cout << endl;
ret.push_back({count_common_roads(thing), v});
} else {
if (ans[v]==1 && mx == -1) {
// for (int X:thing) cout << X << " "; cout << endl;
mx = count_common_roads(thing);
}
}
thing.pop_back();
}
mx = max(mx, (*max_element(ret.begin(), ret.end())).first);
for (auto [val, v]:ret) {
if (val==mx) golden.push_back(v);
ans[v] = (val==mx);
}
}
}
sort(golden.begin(), golden.end());
golden.erase(unique(golden.begin(), golden.end()), golden.end());
// for (int X:golden) cout << X << " "; cout << endl;
return golden;
}
Compilation message
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:19:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for (int i=0;i<U.size();i++) {
| ~^~~~~~~~~
simurgh.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for (int i=0;i<U.size();i++) ans[i] = -1;
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
correct |
2 |
Correct |
1 ms |
348 KB |
correct |
3 |
Correct |
0 ms |
348 KB |
correct |
4 |
Correct |
0 ms |
348 KB |
correct |
5 |
Correct |
0 ms |
348 KB |
correct |
6 |
Correct |
1 ms |
348 KB |
correct |
7 |
Correct |
0 ms |
348 KB |
correct |
8 |
Correct |
0 ms |
348 KB |
correct |
9 |
Correct |
0 ms |
348 KB |
correct |
10 |
Correct |
0 ms |
348 KB |
correct |
11 |
Correct |
1 ms |
348 KB |
correct |
12 |
Correct |
0 ms |
348 KB |
correct |
13 |
Correct |
0 ms |
348 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
correct |
2 |
Correct |
1 ms |
348 KB |
correct |
3 |
Correct |
0 ms |
348 KB |
correct |
4 |
Correct |
0 ms |
348 KB |
correct |
5 |
Correct |
0 ms |
348 KB |
correct |
6 |
Correct |
1 ms |
348 KB |
correct |
7 |
Correct |
0 ms |
348 KB |
correct |
8 |
Correct |
0 ms |
348 KB |
correct |
9 |
Correct |
0 ms |
348 KB |
correct |
10 |
Correct |
0 ms |
348 KB |
correct |
11 |
Correct |
1 ms |
348 KB |
correct |
12 |
Correct |
0 ms |
348 KB |
correct |
13 |
Correct |
0 ms |
348 KB |
correct |
14 |
Correct |
1 ms |
348 KB |
correct |
15 |
Correct |
1 ms |
344 KB |
correct |
16 |
Correct |
2 ms |
344 KB |
correct |
17 |
Correct |
1 ms |
348 KB |
correct |
18 |
Correct |
1 ms |
348 KB |
correct |
19 |
Correct |
2 ms |
348 KB |
correct |
20 |
Correct |
1 ms |
348 KB |
correct |
21 |
Correct |
2 ms |
344 KB |
correct |
22 |
Correct |
1 ms |
348 KB |
correct |
23 |
Correct |
2 ms |
348 KB |
correct |
24 |
Correct |
1 ms |
348 KB |
correct |
25 |
Correct |
0 ms |
348 KB |
correct |
26 |
Correct |
1 ms |
600 KB |
correct |
27 |
Correct |
1 ms |
344 KB |
correct |
28 |
Correct |
1 ms |
348 KB |
correct |
29 |
Correct |
0 ms |
348 KB |
correct |
30 |
Correct |
1 ms |
344 KB |
correct |
31 |
Correct |
1 ms |
348 KB |
correct |
32 |
Correct |
1 ms |
348 KB |
correct |
33 |
Correct |
1 ms |
348 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
correct |
2 |
Correct |
1 ms |
348 KB |
correct |
3 |
Correct |
0 ms |
348 KB |
correct |
4 |
Correct |
0 ms |
348 KB |
correct |
5 |
Correct |
0 ms |
348 KB |
correct |
6 |
Correct |
1 ms |
348 KB |
correct |
7 |
Correct |
0 ms |
348 KB |
correct |
8 |
Correct |
0 ms |
348 KB |
correct |
9 |
Correct |
0 ms |
348 KB |
correct |
10 |
Correct |
0 ms |
348 KB |
correct |
11 |
Correct |
1 ms |
348 KB |
correct |
12 |
Correct |
0 ms |
348 KB |
correct |
13 |
Correct |
0 ms |
348 KB |
correct |
14 |
Correct |
1 ms |
348 KB |
correct |
15 |
Correct |
1 ms |
344 KB |
correct |
16 |
Correct |
2 ms |
344 KB |
correct |
17 |
Correct |
1 ms |
348 KB |
correct |
18 |
Correct |
1 ms |
348 KB |
correct |
19 |
Correct |
2 ms |
348 KB |
correct |
20 |
Correct |
1 ms |
348 KB |
correct |
21 |
Correct |
2 ms |
344 KB |
correct |
22 |
Correct |
1 ms |
348 KB |
correct |
23 |
Correct |
2 ms |
348 KB |
correct |
24 |
Correct |
1 ms |
348 KB |
correct |
25 |
Correct |
0 ms |
348 KB |
correct |
26 |
Correct |
1 ms |
600 KB |
correct |
27 |
Correct |
1 ms |
344 KB |
correct |
28 |
Correct |
1 ms |
348 KB |
correct |
29 |
Correct |
0 ms |
348 KB |
correct |
30 |
Correct |
1 ms |
344 KB |
correct |
31 |
Correct |
1 ms |
348 KB |
correct |
32 |
Correct |
1 ms |
348 KB |
correct |
33 |
Correct |
1 ms |
348 KB |
correct |
34 |
Correct |
88 ms |
1372 KB |
correct |
35 |
Correct |
83 ms |
1768 KB |
correct |
36 |
Correct |
59 ms |
1372 KB |
correct |
37 |
Correct |
6 ms |
344 KB |
correct |
38 |
Correct |
84 ms |
1628 KB |
correct |
39 |
Correct |
77 ms |
1676 KB |
correct |
40 |
Correct |
57 ms |
1372 KB |
correct |
41 |
Correct |
86 ms |
1624 KB |
correct |
42 |
Correct |
82 ms |
1628 KB |
correct |
43 |
Correct |
48 ms |
1112 KB |
correct |
44 |
Correct |
39 ms |
860 KB |
correct |
45 |
Correct |
45 ms |
1116 KB |
correct |
46 |
Correct |
34 ms |
860 KB |
correct |
47 |
Correct |
15 ms |
732 KB |
correct |
48 |
Correct |
2 ms |
348 KB |
correct |
49 |
Correct |
7 ms |
348 KB |
correct |
50 |
Correct |
18 ms |
744 KB |
correct |
51 |
Correct |
45 ms |
1140 KB |
correct |
52 |
Correct |
41 ms |
860 KB |
correct |
53 |
Correct |
34 ms |
860 KB |
correct |
54 |
Correct |
47 ms |
1116 KB |
correct |
55 |
Correct |
43 ms |
1112 KB |
correct |
56 |
Correct |
44 ms |
1112 KB |
correct |
57 |
Correct |
44 ms |
1116 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
correct |
2 |
Correct |
0 ms |
344 KB |
correct |
3 |
Incorrect |
72 ms |
3672 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
correct |
2 |
Correct |
1 ms |
348 KB |
correct |
3 |
Correct |
0 ms |
348 KB |
correct |
4 |
Correct |
0 ms |
348 KB |
correct |
5 |
Correct |
0 ms |
348 KB |
correct |
6 |
Correct |
1 ms |
348 KB |
correct |
7 |
Correct |
0 ms |
348 KB |
correct |
8 |
Correct |
0 ms |
348 KB |
correct |
9 |
Correct |
0 ms |
348 KB |
correct |
10 |
Correct |
0 ms |
348 KB |
correct |
11 |
Correct |
1 ms |
348 KB |
correct |
12 |
Correct |
0 ms |
348 KB |
correct |
13 |
Correct |
0 ms |
348 KB |
correct |
14 |
Correct |
1 ms |
348 KB |
correct |
15 |
Correct |
1 ms |
344 KB |
correct |
16 |
Correct |
2 ms |
344 KB |
correct |
17 |
Correct |
1 ms |
348 KB |
correct |
18 |
Correct |
1 ms |
348 KB |
correct |
19 |
Correct |
2 ms |
348 KB |
correct |
20 |
Correct |
1 ms |
348 KB |
correct |
21 |
Correct |
2 ms |
344 KB |
correct |
22 |
Correct |
1 ms |
348 KB |
correct |
23 |
Correct |
2 ms |
348 KB |
correct |
24 |
Correct |
1 ms |
348 KB |
correct |
25 |
Correct |
0 ms |
348 KB |
correct |
26 |
Correct |
1 ms |
600 KB |
correct |
27 |
Correct |
1 ms |
344 KB |
correct |
28 |
Correct |
1 ms |
348 KB |
correct |
29 |
Correct |
0 ms |
348 KB |
correct |
30 |
Correct |
1 ms |
344 KB |
correct |
31 |
Correct |
1 ms |
348 KB |
correct |
32 |
Correct |
1 ms |
348 KB |
correct |
33 |
Correct |
1 ms |
348 KB |
correct |
34 |
Correct |
88 ms |
1372 KB |
correct |
35 |
Correct |
83 ms |
1768 KB |
correct |
36 |
Correct |
59 ms |
1372 KB |
correct |
37 |
Correct |
6 ms |
344 KB |
correct |
38 |
Correct |
84 ms |
1628 KB |
correct |
39 |
Correct |
77 ms |
1676 KB |
correct |
40 |
Correct |
57 ms |
1372 KB |
correct |
41 |
Correct |
86 ms |
1624 KB |
correct |
42 |
Correct |
82 ms |
1628 KB |
correct |
43 |
Correct |
48 ms |
1112 KB |
correct |
44 |
Correct |
39 ms |
860 KB |
correct |
45 |
Correct |
45 ms |
1116 KB |
correct |
46 |
Correct |
34 ms |
860 KB |
correct |
47 |
Correct |
15 ms |
732 KB |
correct |
48 |
Correct |
2 ms |
348 KB |
correct |
49 |
Correct |
7 ms |
348 KB |
correct |
50 |
Correct |
18 ms |
744 KB |
correct |
51 |
Correct |
45 ms |
1140 KB |
correct |
52 |
Correct |
41 ms |
860 KB |
correct |
53 |
Correct |
34 ms |
860 KB |
correct |
54 |
Correct |
47 ms |
1116 KB |
correct |
55 |
Correct |
43 ms |
1112 KB |
correct |
56 |
Correct |
44 ms |
1112 KB |
correct |
57 |
Correct |
44 ms |
1116 KB |
correct |
58 |
Correct |
0 ms |
348 KB |
correct |
59 |
Correct |
0 ms |
344 KB |
correct |
60 |
Incorrect |
72 ms |
3672 KB |
WA in grader: NO |
61 |
Halted |
0 ms |
0 KB |
- |