#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
const int N=505;
int n,m,mark[N],comp[N],cnt[N],pdge[N],Max[N],par[N];
vector<int> edge,ans;
vector<pair<int,int>> g[N];
bool cmp(pair<int,int> a,pair<int,int> b){
return mark[a.F]>mark[b.F];
}
void dfs(int u,int col){
comp[u]=col;
for(auto [v,id] : g[u]){
if(comp[v]) continue ;
edge.pb(id);
dfs(v,col);
}
}
int ask(vector<int> &vec){
return count_common_roads(vec);
}
vector<int> find_roads(int _n,vector<int> u,vector<int> v){
vector<int> ans;
n=_n,m=u.size();
f(i,0,m) g[u[i]].pb({v[i],i}),g[v[i]].pb({u[i],i});
queue<int> q;
q.push(0);
mark[0]=1;
while(q.size()){
edge.clear();
int u=q.front();
q.pop();
f(i,0,n) comp[i]=Max[i]=0,cnt[i]=-1; comp[u]=1;
int col=0;
f(i,0,g[u].size()) if(g[u][i].F==par[u]) swap(g[u][0],g[u][i]);
for(auto [v,id] : g[u]){
if(comp[v]==0){
col++;
dfs(v,col);
pdge[col]=id;
edge.pb(id);
}
}
int res=ask(edge);
for(auto [v,id] : g[u]){
if(pdge[comp[v]]==id){
cnt[v]=res;
maxm(Max[comp[v]],cnt[v]);
}
}
for(auto [v,id] : g[u]){
if(pdge[comp[v]]==id || mark[v]) continue ;
vector<int> vec;
for(auto x : edge){
if(x!=pdge[comp[v]])
vec.pb(x);
}
vec.pb(id);
cnt[v]=ask(vec);
maxm(Max[comp[v]],cnt[v]);
}
for(auto [v,id] : g[u]){
if(Max[comp[v]]==cnt[v] && mark[v]==0){
mark[v]=1;
par[v]=u;
q.push(v);
ans.pb(id);
}
}
}
//dbgv(ans);
return ans;
}
Compilation message
simurgh.cpp: In function 'void dfs(int, int)':
simurgh.cpp:35:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
35 | for(auto [v,id] : g[u]){
| ^
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:9:18: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
9 | #define f(i,a,b) for(int i=a;i<b;i++)
| ^~~
simurgh.cpp:55:3: note: in expansion of macro 'f'
55 | f(i,0,n) comp[i]=Max[i]=0,cnt[i]=-1; comp[u]=1;
| ^
simurgh.cpp:55:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
55 | f(i,0,n) comp[i]=Max[i]=0,cnt[i]=-1; comp[u]=1;
| ^~~~
simurgh.cpp:9:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
9 | #define f(i,a,b) for(int i=a;i<b;i++)
......
57 | f(i,0,g[u].size()) if(g[u][i].F==par[u]) swap(g[u][0],g[u][i]);
| ~~~~~~~~~~~~~~~
simurgh.cpp:57:3: note: in expansion of macro 'f'
57 | f(i,0,g[u].size()) if(g[u][i].F==par[u]) swap(g[u][0],g[u][i]);
| ^
simurgh.cpp:58:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
58 | for(auto [v,id] : g[u]){
| ^
simurgh.cpp:67:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
67 | for(auto [v,id] : g[u]){
| ^
simurgh.cpp:73:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
73 | for(auto [v,id] : g[u]){
| ^
simurgh.cpp:85:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
85 | for(auto [v,id] : g[u]){
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
1 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
1 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
1 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
1 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
1 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
1 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
1 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
1 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
14 |
Correct |
2 ms |
340 KB |
correct |
15 |
Correct |
1 ms |
340 KB |
correct |
16 |
Correct |
1 ms |
340 KB |
correct |
17 |
Correct |
2 ms |
340 KB |
correct |
18 |
Correct |
1 ms |
340 KB |
correct |
19 |
Correct |
3 ms |
340 KB |
correct |
20 |
Correct |
2 ms |
340 KB |
correct |
21 |
Correct |
2 ms |
340 KB |
correct |
22 |
Correct |
2 ms |
340 KB |
correct |
23 |
Correct |
1 ms |
340 KB |
correct |
24 |
Correct |
1 ms |
340 KB |
correct |
25 |
Correct |
1 ms |
212 KB |
correct |
26 |
Correct |
1 ms |
340 KB |
correct |
27 |
Correct |
2 ms |
340 KB |
correct |
28 |
Correct |
1 ms |
212 KB |
correct |
29 |
Correct |
1 ms |
212 KB |
correct |
30 |
Correct |
1 ms |
340 KB |
correct |
31 |
Correct |
1 ms |
340 KB |
correct |
32 |
Correct |
2 ms |
340 KB |
correct |
33 |
Correct |
2 ms |
340 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
1 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
1 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
1 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
1 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
14 |
Correct |
2 ms |
340 KB |
correct |
15 |
Correct |
1 ms |
340 KB |
correct |
16 |
Correct |
1 ms |
340 KB |
correct |
17 |
Correct |
2 ms |
340 KB |
correct |
18 |
Correct |
1 ms |
340 KB |
correct |
19 |
Correct |
3 ms |
340 KB |
correct |
20 |
Correct |
2 ms |
340 KB |
correct |
21 |
Correct |
2 ms |
340 KB |
correct |
22 |
Correct |
2 ms |
340 KB |
correct |
23 |
Correct |
1 ms |
340 KB |
correct |
24 |
Correct |
1 ms |
340 KB |
correct |
25 |
Correct |
1 ms |
212 KB |
correct |
26 |
Correct |
1 ms |
340 KB |
correct |
27 |
Correct |
2 ms |
340 KB |
correct |
28 |
Correct |
1 ms |
212 KB |
correct |
29 |
Correct |
1 ms |
212 KB |
correct |
30 |
Correct |
1 ms |
340 KB |
correct |
31 |
Correct |
1 ms |
340 KB |
correct |
32 |
Correct |
2 ms |
340 KB |
correct |
33 |
Correct |
2 ms |
340 KB |
correct |
34 |
Correct |
128 ms |
1348 KB |
correct |
35 |
Correct |
130 ms |
1520 KB |
correct |
36 |
Correct |
78 ms |
1340 KB |
correct |
37 |
Correct |
11 ms |
340 KB |
correct |
38 |
Correct |
183 ms |
1536 KB |
correct |
39 |
Correct |
78 ms |
1352 KB |
correct |
40 |
Correct |
82 ms |
1236 KB |
correct |
41 |
Correct |
23 ms |
1568 KB |
correct |
42 |
Correct |
22 ms |
1496 KB |
correct |
43 |
Correct |
72 ms |
1136 KB |
correct |
44 |
Correct |
62 ms |
876 KB |
correct |
45 |
Correct |
79 ms |
924 KB |
correct |
46 |
Correct |
60 ms |
820 KB |
correct |
47 |
Correct |
25 ms |
468 KB |
correct |
48 |
Correct |
5 ms |
340 KB |
correct |
49 |
Correct |
9 ms |
408 KB |
correct |
50 |
Correct |
26 ms |
584 KB |
correct |
51 |
Correct |
71 ms |
936 KB |
correct |
52 |
Correct |
72 ms |
864 KB |
correct |
53 |
Correct |
60 ms |
724 KB |
correct |
54 |
Correct |
86 ms |
1140 KB |
correct |
55 |
Correct |
73 ms |
836 KB |
correct |
56 |
Correct |
72 ms |
940 KB |
correct |
57 |
Correct |
79 ms |
948 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Incorrect |
117 ms |
3416 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
1 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
1 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
1 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
1 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
14 |
Correct |
2 ms |
340 KB |
correct |
15 |
Correct |
1 ms |
340 KB |
correct |
16 |
Correct |
1 ms |
340 KB |
correct |
17 |
Correct |
2 ms |
340 KB |
correct |
18 |
Correct |
1 ms |
340 KB |
correct |
19 |
Correct |
3 ms |
340 KB |
correct |
20 |
Correct |
2 ms |
340 KB |
correct |
21 |
Correct |
2 ms |
340 KB |
correct |
22 |
Correct |
2 ms |
340 KB |
correct |
23 |
Correct |
1 ms |
340 KB |
correct |
24 |
Correct |
1 ms |
340 KB |
correct |
25 |
Correct |
1 ms |
212 KB |
correct |
26 |
Correct |
1 ms |
340 KB |
correct |
27 |
Correct |
2 ms |
340 KB |
correct |
28 |
Correct |
1 ms |
212 KB |
correct |
29 |
Correct |
1 ms |
212 KB |
correct |
30 |
Correct |
1 ms |
340 KB |
correct |
31 |
Correct |
1 ms |
340 KB |
correct |
32 |
Correct |
2 ms |
340 KB |
correct |
33 |
Correct |
2 ms |
340 KB |
correct |
34 |
Correct |
128 ms |
1348 KB |
correct |
35 |
Correct |
130 ms |
1520 KB |
correct |
36 |
Correct |
78 ms |
1340 KB |
correct |
37 |
Correct |
11 ms |
340 KB |
correct |
38 |
Correct |
183 ms |
1536 KB |
correct |
39 |
Correct |
78 ms |
1352 KB |
correct |
40 |
Correct |
82 ms |
1236 KB |
correct |
41 |
Correct |
23 ms |
1568 KB |
correct |
42 |
Correct |
22 ms |
1496 KB |
correct |
43 |
Correct |
72 ms |
1136 KB |
correct |
44 |
Correct |
62 ms |
876 KB |
correct |
45 |
Correct |
79 ms |
924 KB |
correct |
46 |
Correct |
60 ms |
820 KB |
correct |
47 |
Correct |
25 ms |
468 KB |
correct |
48 |
Correct |
5 ms |
340 KB |
correct |
49 |
Correct |
9 ms |
408 KB |
correct |
50 |
Correct |
26 ms |
584 KB |
correct |
51 |
Correct |
71 ms |
936 KB |
correct |
52 |
Correct |
72 ms |
864 KB |
correct |
53 |
Correct |
60 ms |
724 KB |
correct |
54 |
Correct |
86 ms |
1140 KB |
correct |
55 |
Correct |
73 ms |
836 KB |
correct |
56 |
Correct |
72 ms |
940 KB |
correct |
57 |
Correct |
79 ms |
948 KB |
correct |
58 |
Correct |
1 ms |
212 KB |
correct |
59 |
Correct |
0 ms |
212 KB |
correct |
60 |
Incorrect |
117 ms |
3416 KB |
WA in grader: NO |
61 |
Halted |
0 ms |
0 KB |
- |