#include<iostream>
#include<vector>
#include<unordered_set>
#include<unordered_map>
#include"simurgh.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define N 250
vector<P> g[N];
unordered_set<int> vis;
vector<int> edges;
int blg[N];
void dfs(ll x,ll eid,ll root){
if(vis.find(x)!=vis.end())return;
vis.insert(x);
if(-1!=eid)edges.push_back(eid);
blg[x]=root;
for(auto y:g[x]){
dfs(y.first,y.second,root);
}
}
int isans[N*N];
vector<int> find_roads(int n,vector<int> u,vector<int> v){
for(int i=0;i<u.size();i++){
g[u[i]].push_back(make_pair(v[i],i));
g[v[i]].push_back(make_pair(u[i],i));
isans[i]=-1;
}
vector<int> ans;
for(int i=0;i<n;i++){
edges.clear();
vis.clear();
vis.insert(i);
for(int j=0;j<n;j++){
dfs(j,-1,j);
}
unordered_map<ll,vector<int> >mas;
for(auto e:g[i]){
mas[blg[e.first]].push_back(e.second);
}
for(auto v:mas){
for(auto vv:mas){
if(v!=vv)edges.push_back(vv.second[0]);
}
int ma=-1;
unordered_map<int,int> sav;
int resu=-1,resd=-1;
for(auto e:v.second){
edges.push_back(e);
//if(edges.size()<n-1)cout<<1/0<<endl;
if(isans[e]==1){
if(resu==-1)resu=count_common_roads(edges);
sav[e]=resu;
}
if(isans[e]==0){
if(resd==-1)resd=count_common_roads(edges);
sav[e]=resd;
}
if(isans[e]==-1){
sav[e]=count_common_roads(edges);
}
chmax(ma,sav[e]);
edges.pop_back();
}
for(auto e:v.second){
if(sav[e]==ma){
if(isans[e]==-1)ans.push_back(e);
isans[e]=1;
}
else isans[e]=0;
}
for(auto vv:mas){
if(v!=vv)edges.pop_back();
}
}
}
if(ans.size()!=n-1)cout<<1/0<<endl;
return ans;
}
Compilation message
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:30:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<u.size();i++){
~^~~~~~~~~
simurgh.cpp:83:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(ans.size()!=n-1)cout<<1/0<<endl;
~~~~~~~~~~^~~~~
simurgh.cpp:83:31: warning: division by zero [-Wdiv-by-zero]
if(ans.size()!=n-1)cout<<1/0<<endl;
~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
correct |
2 |
Correct |
2 ms |
376 KB |
correct |
3 |
Correct |
2 ms |
376 KB |
correct |
4 |
Correct |
2 ms |
376 KB |
correct |
5 |
Correct |
2 ms |
376 KB |
correct |
6 |
Correct |
2 ms |
376 KB |
correct |
7 |
Correct |
2 ms |
376 KB |
correct |
8 |
Correct |
2 ms |
256 KB |
correct |
9 |
Correct |
11 ms |
256 KB |
correct |
10 |
Correct |
2 ms |
248 KB |
correct |
11 |
Correct |
2 ms |
252 KB |
correct |
12 |
Correct |
2 ms |
256 KB |
correct |
13 |
Correct |
2 ms |
376 KB |
correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
correct |
2 |
Correct |
2 ms |
376 KB |
correct |
3 |
Correct |
2 ms |
376 KB |
correct |
4 |
Correct |
2 ms |
376 KB |
correct |
5 |
Correct |
2 ms |
376 KB |
correct |
6 |
Correct |
2 ms |
376 KB |
correct |
7 |
Correct |
2 ms |
376 KB |
correct |
8 |
Correct |
2 ms |
256 KB |
correct |
9 |
Correct |
11 ms |
256 KB |
correct |
10 |
Correct |
2 ms |
248 KB |
correct |
11 |
Correct |
2 ms |
252 KB |
correct |
12 |
Correct |
2 ms |
256 KB |
correct |
13 |
Correct |
2 ms |
376 KB |
correct |
14 |
Correct |
7 ms |
376 KB |
correct |
15 |
Correct |
6 ms |
376 KB |
correct |
16 |
Correct |
7 ms |
376 KB |
correct |
17 |
Correct |
6 ms |
376 KB |
correct |
18 |
Correct |
4 ms |
376 KB |
correct |
19 |
Correct |
6 ms |
376 KB |
correct |
20 |
Correct |
6 ms |
380 KB |
correct |
21 |
Correct |
6 ms |
376 KB |
correct |
22 |
Correct |
5 ms |
376 KB |
correct |
23 |
Correct |
5 ms |
376 KB |
correct |
24 |
Correct |
4 ms |
376 KB |
correct |
25 |
Correct |
3 ms |
376 KB |
correct |
26 |
Correct |
4 ms |
376 KB |
correct |
27 |
Correct |
4 ms |
376 KB |
correct |
28 |
Correct |
4 ms |
376 KB |
correct |
29 |
Correct |
3 ms |
376 KB |
correct |
30 |
Correct |
4 ms |
380 KB |
correct |
31 |
Correct |
17 ms |
376 KB |
correct |
32 |
Correct |
4 ms |
376 KB |
correct |
33 |
Correct |
5 ms |
376 KB |
correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
correct |
2 |
Correct |
2 ms |
376 KB |
correct |
3 |
Correct |
2 ms |
376 KB |
correct |
4 |
Correct |
2 ms |
376 KB |
correct |
5 |
Correct |
2 ms |
376 KB |
correct |
6 |
Correct |
2 ms |
376 KB |
correct |
7 |
Correct |
2 ms |
376 KB |
correct |
8 |
Correct |
2 ms |
256 KB |
correct |
9 |
Correct |
11 ms |
256 KB |
correct |
10 |
Correct |
2 ms |
248 KB |
correct |
11 |
Correct |
2 ms |
252 KB |
correct |
12 |
Correct |
2 ms |
256 KB |
correct |
13 |
Correct |
2 ms |
376 KB |
correct |
14 |
Correct |
7 ms |
376 KB |
correct |
15 |
Correct |
6 ms |
376 KB |
correct |
16 |
Correct |
7 ms |
376 KB |
correct |
17 |
Correct |
6 ms |
376 KB |
correct |
18 |
Correct |
4 ms |
376 KB |
correct |
19 |
Correct |
6 ms |
376 KB |
correct |
20 |
Correct |
6 ms |
380 KB |
correct |
21 |
Correct |
6 ms |
376 KB |
correct |
22 |
Correct |
5 ms |
376 KB |
correct |
23 |
Correct |
5 ms |
376 KB |
correct |
24 |
Correct |
4 ms |
376 KB |
correct |
25 |
Correct |
3 ms |
376 KB |
correct |
26 |
Correct |
4 ms |
376 KB |
correct |
27 |
Correct |
4 ms |
376 KB |
correct |
28 |
Correct |
4 ms |
376 KB |
correct |
29 |
Correct |
3 ms |
376 KB |
correct |
30 |
Correct |
4 ms |
380 KB |
correct |
31 |
Correct |
17 ms |
376 KB |
correct |
32 |
Correct |
4 ms |
376 KB |
correct |
33 |
Correct |
5 ms |
376 KB |
correct |
34 |
Correct |
385 ms |
1996 KB |
correct |
35 |
Correct |
362 ms |
2140 KB |
correct |
36 |
Correct |
258 ms |
2040 KB |
correct |
37 |
Correct |
26 ms |
376 KB |
correct |
38 |
Correct |
377 ms |
2168 KB |
correct |
39 |
Correct |
325 ms |
2168 KB |
correct |
40 |
Correct |
256 ms |
2044 KB |
correct |
41 |
Correct |
399 ms |
2296 KB |
correct |
42 |
Correct |
377 ms |
2296 KB |
correct |
43 |
Correct |
221 ms |
1656 KB |
correct |
44 |
Correct |
195 ms |
1272 KB |
correct |
45 |
Correct |
195 ms |
1272 KB |
correct |
46 |
Correct |
151 ms |
1272 KB |
correct |
47 |
Correct |
72 ms |
760 KB |
correct |
48 |
Correct |
15 ms |
376 KB |
correct |
49 |
Correct |
29 ms |
504 KB |
correct |
50 |
Correct |
78 ms |
760 KB |
correct |
51 |
Correct |
203 ms |
1308 KB |
correct |
52 |
Correct |
169 ms |
1276 KB |
correct |
53 |
Correct |
148 ms |
1016 KB |
correct |
54 |
Correct |
222 ms |
1656 KB |
correct |
55 |
Correct |
195 ms |
1276 KB |
correct |
56 |
Correct |
192 ms |
1296 KB |
correct |
57 |
Correct |
195 ms |
1400 KB |
correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
476 KB |
correct |
2 |
Correct |
2 ms |
376 KB |
correct |
3 |
Runtime error |
34 ms |
3520 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
correct |
2 |
Correct |
2 ms |
376 KB |
correct |
3 |
Correct |
2 ms |
376 KB |
correct |
4 |
Correct |
2 ms |
376 KB |
correct |
5 |
Correct |
2 ms |
376 KB |
correct |
6 |
Correct |
2 ms |
376 KB |
correct |
7 |
Correct |
2 ms |
376 KB |
correct |
8 |
Correct |
2 ms |
256 KB |
correct |
9 |
Correct |
11 ms |
256 KB |
correct |
10 |
Correct |
2 ms |
248 KB |
correct |
11 |
Correct |
2 ms |
252 KB |
correct |
12 |
Correct |
2 ms |
256 KB |
correct |
13 |
Correct |
2 ms |
376 KB |
correct |
14 |
Correct |
7 ms |
376 KB |
correct |
15 |
Correct |
6 ms |
376 KB |
correct |
16 |
Correct |
7 ms |
376 KB |
correct |
17 |
Correct |
6 ms |
376 KB |
correct |
18 |
Correct |
4 ms |
376 KB |
correct |
19 |
Correct |
6 ms |
376 KB |
correct |
20 |
Correct |
6 ms |
380 KB |
correct |
21 |
Correct |
6 ms |
376 KB |
correct |
22 |
Correct |
5 ms |
376 KB |
correct |
23 |
Correct |
5 ms |
376 KB |
correct |
24 |
Correct |
4 ms |
376 KB |
correct |
25 |
Correct |
3 ms |
376 KB |
correct |
26 |
Correct |
4 ms |
376 KB |
correct |
27 |
Correct |
4 ms |
376 KB |
correct |
28 |
Correct |
4 ms |
376 KB |
correct |
29 |
Correct |
3 ms |
376 KB |
correct |
30 |
Correct |
4 ms |
380 KB |
correct |
31 |
Correct |
17 ms |
376 KB |
correct |
32 |
Correct |
4 ms |
376 KB |
correct |
33 |
Correct |
5 ms |
376 KB |
correct |
34 |
Correct |
385 ms |
1996 KB |
correct |
35 |
Correct |
362 ms |
2140 KB |
correct |
36 |
Correct |
258 ms |
2040 KB |
correct |
37 |
Correct |
26 ms |
376 KB |
correct |
38 |
Correct |
377 ms |
2168 KB |
correct |
39 |
Correct |
325 ms |
2168 KB |
correct |
40 |
Correct |
256 ms |
2044 KB |
correct |
41 |
Correct |
399 ms |
2296 KB |
correct |
42 |
Correct |
377 ms |
2296 KB |
correct |
43 |
Correct |
221 ms |
1656 KB |
correct |
44 |
Correct |
195 ms |
1272 KB |
correct |
45 |
Correct |
195 ms |
1272 KB |
correct |
46 |
Correct |
151 ms |
1272 KB |
correct |
47 |
Correct |
72 ms |
760 KB |
correct |
48 |
Correct |
15 ms |
376 KB |
correct |
49 |
Correct |
29 ms |
504 KB |
correct |
50 |
Correct |
78 ms |
760 KB |
correct |
51 |
Correct |
203 ms |
1308 KB |
correct |
52 |
Correct |
169 ms |
1276 KB |
correct |
53 |
Correct |
148 ms |
1016 KB |
correct |
54 |
Correct |
222 ms |
1656 KB |
correct |
55 |
Correct |
195 ms |
1276 KB |
correct |
56 |
Correct |
192 ms |
1296 KB |
correct |
57 |
Correct |
195 ms |
1400 KB |
correct |
58 |
Correct |
2 ms |
476 KB |
correct |
59 |
Correct |
2 ms |
376 KB |
correct |
60 |
Runtime error |
34 ms |
3520 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
61 |
Halted |
0 ms |
0 KB |
- |