#include <bits/stdc++.h>
#include "simurgh.h"
using namespace std;
const int c=502;
vector<int> kerd;
vector<pair<int, int> > p;
int sz[c][c], st[c*c], v[c], n, m;
void dfs(int a, int b) {
//cout << "dfs " << a << " " << b << "\n";
v[a]=b;
for (int i=0; i<n; i++) {
if (sz[a][i]!=-1 && !v[i]) {
kerd.push_back(sz[a][i]);
dfs(i, b);
}
}
}
/*
int count_common_roads(vector<int> sz) {
for (int i=0; i<n-1; i++) {
cout << sz[i] << " ";
}
cout << "\n";
int x; cin >> x;
return x;
}
*/
vector<int> find_roads(int k, vector<int> x, vector<int> y) {
m=x.size(), n=k;
for (int i=0; i<n; i++) for (int j=0; j<n; j++) sz[i][j]=-1;
for (int i=0; i<m; i++) {
int a=x[i], b=y[i];
sz[a][b]=i, sz[b][a]=i;
}
for (int i=0; i<m; i++) {
if (!st[i]) {
kerd.clear(), p.clear();
int a=x[i], b=y[i], db=0;
//cout << "kulon " << a << " " << b << "\n";
for (int j=0; j<n; j++) v[j]=0;
v[b]=1, dfs(a, 1), dfs(b, 2);
for (int i=0; i<m; i++) if (v[x[i]]!=v[y[i]]) if (!st[i] || (st[i]==1 && !db)) {
db+=st[i];
kerd.push_back(i);
p.push_back({count_common_roads(kerd), i});
kerd.pop_back();
}
sort(p.rbegin(), p.rend());
for (int i=0; i<p.size(); i++) {
int se=p[i].second;
if (p[i].first==p[0].first) st[se]=1;
else st[se]=-1;
}
}
}
kerd.clear();
for (int i=0; i<m; i++) if (st[i]==1) kerd.push_back(i);
return kerd;
}
Compilation message
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:49:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for (int i=0; i<p.size(); i++) {
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
correct |
2 |
Correct |
1 ms |
384 KB |
correct |
3 |
Correct |
0 ms |
384 KB |
correct |
4 |
Correct |
0 ms |
384 KB |
correct |
5 |
Correct |
0 ms |
384 KB |
correct |
6 |
Correct |
1 ms |
384 KB |
correct |
7 |
Correct |
0 ms |
384 KB |
correct |
8 |
Correct |
1 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 |
1 ms |
384 KB |
correct |
3 |
Correct |
0 ms |
384 KB |
correct |
4 |
Correct |
0 ms |
384 KB |
correct |
5 |
Correct |
0 ms |
384 KB |
correct |
6 |
Correct |
1 ms |
384 KB |
correct |
7 |
Correct |
0 ms |
384 KB |
correct |
8 |
Correct |
1 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 |
384 KB |
correct |
15 |
Correct |
3 ms |
384 KB |
correct |
16 |
Correct |
3 ms |
384 KB |
correct |
17 |
Correct |
3 ms |
384 KB |
correct |
18 |
Correct |
2 ms |
512 KB |
correct |
19 |
Correct |
3 ms |
384 KB |
correct |
20 |
Correct |
2 ms |
384 KB |
correct |
21 |
Correct |
2 ms |
384 KB |
correct |
22 |
Correct |
2 ms |
384 KB |
correct |
23 |
Correct |
2 ms |
384 KB |
correct |
24 |
Correct |
2 ms |
384 KB |
correct |
25 |
Correct |
1 ms |
384 KB |
correct |
26 |
Correct |
2 ms |
384 KB |
correct |
27 |
Correct |
2 ms |
384 KB |
correct |
28 |
Correct |
1 ms |
384 KB |
correct |
29 |
Correct |
1 ms |
384 KB |
correct |
30 |
Correct |
2 ms |
384 KB |
correct |
31 |
Correct |
2 ms |
384 KB |
correct |
32 |
Correct |
2 ms |
384 KB |
correct |
33 |
Correct |
2 ms |
384 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
correct |
2 |
Correct |
1 ms |
384 KB |
correct |
3 |
Correct |
0 ms |
384 KB |
correct |
4 |
Correct |
0 ms |
384 KB |
correct |
5 |
Correct |
0 ms |
384 KB |
correct |
6 |
Correct |
1 ms |
384 KB |
correct |
7 |
Correct |
0 ms |
384 KB |
correct |
8 |
Correct |
1 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 |
384 KB |
correct |
15 |
Correct |
3 ms |
384 KB |
correct |
16 |
Correct |
3 ms |
384 KB |
correct |
17 |
Correct |
3 ms |
384 KB |
correct |
18 |
Correct |
2 ms |
512 KB |
correct |
19 |
Correct |
3 ms |
384 KB |
correct |
20 |
Correct |
2 ms |
384 KB |
correct |
21 |
Correct |
2 ms |
384 KB |
correct |
22 |
Correct |
2 ms |
384 KB |
correct |
23 |
Correct |
2 ms |
384 KB |
correct |
24 |
Correct |
2 ms |
384 KB |
correct |
25 |
Correct |
1 ms |
384 KB |
correct |
26 |
Correct |
2 ms |
384 KB |
correct |
27 |
Correct |
2 ms |
384 KB |
correct |
28 |
Correct |
1 ms |
384 KB |
correct |
29 |
Correct |
1 ms |
384 KB |
correct |
30 |
Correct |
2 ms |
384 KB |
correct |
31 |
Correct |
2 ms |
384 KB |
correct |
32 |
Correct |
2 ms |
384 KB |
correct |
33 |
Correct |
2 ms |
384 KB |
correct |
34 |
Correct |
231 ms |
1656 KB |
correct |
35 |
Correct |
227 ms |
1656 KB |
correct |
36 |
Correct |
217 ms |
1280 KB |
correct |
37 |
Correct |
37 ms |
768 KB |
correct |
38 |
Correct |
233 ms |
1656 KB |
correct |
39 |
Correct |
218 ms |
1408 KB |
correct |
40 |
Correct |
212 ms |
1280 KB |
correct |
41 |
Correct |
251 ms |
1748 KB |
correct |
42 |
Correct |
235 ms |
1536 KB |
correct |
43 |
Correct |
165 ms |
1152 KB |
correct |
44 |
Correct |
144 ms |
1152 KB |
correct |
45 |
Correct |
160 ms |
1152 KB |
correct |
46 |
Correct |
138 ms |
1024 KB |
correct |
47 |
Correct |
79 ms |
896 KB |
correct |
48 |
Correct |
29 ms |
768 KB |
correct |
49 |
Correct |
37 ms |
768 KB |
correct |
50 |
Correct |
78 ms |
896 KB |
correct |
51 |
Correct |
163 ms |
1236 KB |
correct |
52 |
Correct |
144 ms |
1176 KB |
correct |
53 |
Correct |
134 ms |
1152 KB |
correct |
54 |
Correct |
167 ms |
1272 KB |
correct |
55 |
Correct |
166 ms |
1152 KB |
correct |
56 |
Correct |
167 ms |
1152 KB |
correct |
57 |
Correct |
166 ms |
1272 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
correct |
2 |
Correct |
0 ms |
384 KB |
correct |
3 |
Incorrect |
169 ms |
3320 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
correct |
2 |
Correct |
1 ms |
384 KB |
correct |
3 |
Correct |
0 ms |
384 KB |
correct |
4 |
Correct |
0 ms |
384 KB |
correct |
5 |
Correct |
0 ms |
384 KB |
correct |
6 |
Correct |
1 ms |
384 KB |
correct |
7 |
Correct |
0 ms |
384 KB |
correct |
8 |
Correct |
1 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 |
384 KB |
correct |
15 |
Correct |
3 ms |
384 KB |
correct |
16 |
Correct |
3 ms |
384 KB |
correct |
17 |
Correct |
3 ms |
384 KB |
correct |
18 |
Correct |
2 ms |
512 KB |
correct |
19 |
Correct |
3 ms |
384 KB |
correct |
20 |
Correct |
2 ms |
384 KB |
correct |
21 |
Correct |
2 ms |
384 KB |
correct |
22 |
Correct |
2 ms |
384 KB |
correct |
23 |
Correct |
2 ms |
384 KB |
correct |
24 |
Correct |
2 ms |
384 KB |
correct |
25 |
Correct |
1 ms |
384 KB |
correct |
26 |
Correct |
2 ms |
384 KB |
correct |
27 |
Correct |
2 ms |
384 KB |
correct |
28 |
Correct |
1 ms |
384 KB |
correct |
29 |
Correct |
1 ms |
384 KB |
correct |
30 |
Correct |
2 ms |
384 KB |
correct |
31 |
Correct |
2 ms |
384 KB |
correct |
32 |
Correct |
2 ms |
384 KB |
correct |
33 |
Correct |
2 ms |
384 KB |
correct |
34 |
Correct |
231 ms |
1656 KB |
correct |
35 |
Correct |
227 ms |
1656 KB |
correct |
36 |
Correct |
217 ms |
1280 KB |
correct |
37 |
Correct |
37 ms |
768 KB |
correct |
38 |
Correct |
233 ms |
1656 KB |
correct |
39 |
Correct |
218 ms |
1408 KB |
correct |
40 |
Correct |
212 ms |
1280 KB |
correct |
41 |
Correct |
251 ms |
1748 KB |
correct |
42 |
Correct |
235 ms |
1536 KB |
correct |
43 |
Correct |
165 ms |
1152 KB |
correct |
44 |
Correct |
144 ms |
1152 KB |
correct |
45 |
Correct |
160 ms |
1152 KB |
correct |
46 |
Correct |
138 ms |
1024 KB |
correct |
47 |
Correct |
79 ms |
896 KB |
correct |
48 |
Correct |
29 ms |
768 KB |
correct |
49 |
Correct |
37 ms |
768 KB |
correct |
50 |
Correct |
78 ms |
896 KB |
correct |
51 |
Correct |
163 ms |
1236 KB |
correct |
52 |
Correct |
144 ms |
1176 KB |
correct |
53 |
Correct |
134 ms |
1152 KB |
correct |
54 |
Correct |
167 ms |
1272 KB |
correct |
55 |
Correct |
166 ms |
1152 KB |
correct |
56 |
Correct |
167 ms |
1152 KB |
correct |
57 |
Correct |
166 ms |
1272 KB |
correct |
58 |
Correct |
0 ms |
384 KB |
correct |
59 |
Correct |
0 ms |
384 KB |
correct |
60 |
Incorrect |
169 ms |
3320 KB |
WA in grader: NO |
61 |
Halted |
0 ms |
0 KB |
- |