#include <bits/stdc++.h>
#define pb push_back
#include "simurgh.h"
using namespace std;
const int MAXN = 5e2 + 5;
vector<int> par(MAXN);
vector<pair<int, int> > adj[MAXN];
int fnd(int a){
if(a == par[a]) return a;
return par[a] = fnd(par[a]);
}
void merge(int a, int b){
a = fnd(a), b = fnd(b);
par[b] = a;
}
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
vector<int> r;
int m = u.size();
vector<int> ok(m);
for(int i = 0; i < m; i++){
adj[u[i]].pb({v[i], i});
adj[v[i]].pb({u[i], i});
}
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
par[j] = j;
}
vector<int> ottree;
for(int j = 0; j < n; j++){
if(j == i) continue;
for(auto itr: adj[j]){
if(itr.first == i) continue;
if(fnd(j) == fnd(itr.first)) continue;
ottree.pb(itr.second);
merge(j, itr.first);
}
}
vector<pair<int, int> > vals;
int mx = 0;
for(auto itr: adj[i]){
ottree.pb(itr.second);
int cnt = count_common_roads(ottree);
vals.pb({cnt, itr.second});
mx = max(mx, cnt);
ottree.pop_back();
}
for(auto itr: vals){
if(itr.first == mx){
ok[itr.second] = 1;
}
}
}
for(int i = 0; i < m; i++){
if(ok[i]) r.pb(i);
}
return r;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
correct |
2 |
Correct |
1 ms |
456 KB |
correct |
3 |
Correct |
1 ms |
504 KB |
correct |
4 |
Correct |
1 ms |
336 KB |
correct |
5 |
Correct |
1 ms |
336 KB |
correct |
6 |
Correct |
1 ms |
504 KB |
correct |
7 |
Correct |
1 ms |
336 KB |
correct |
8 |
Correct |
1 ms |
336 KB |
correct |
9 |
Incorrect |
1 ms |
456 KB |
WA in grader: NO |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
correct |
2 |
Correct |
1 ms |
456 KB |
correct |
3 |
Correct |
1 ms |
504 KB |
correct |
4 |
Correct |
1 ms |
336 KB |
correct |
5 |
Correct |
1 ms |
336 KB |
correct |
6 |
Correct |
1 ms |
504 KB |
correct |
7 |
Correct |
1 ms |
336 KB |
correct |
8 |
Correct |
1 ms |
336 KB |
correct |
9 |
Incorrect |
1 ms |
456 KB |
WA in grader: NO |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
correct |
2 |
Correct |
1 ms |
456 KB |
correct |
3 |
Correct |
1 ms |
504 KB |
correct |
4 |
Correct |
1 ms |
336 KB |
correct |
5 |
Correct |
1 ms |
336 KB |
correct |
6 |
Correct |
1 ms |
504 KB |
correct |
7 |
Correct |
1 ms |
336 KB |
correct |
8 |
Correct |
1 ms |
336 KB |
correct |
9 |
Incorrect |
1 ms |
456 KB |
WA in grader: NO |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
correct |
2 |
Correct |
1 ms |
336 KB |
correct |
3 |
Incorrect |
77 ms |
4428 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
correct |
2 |
Correct |
1 ms |
456 KB |
correct |
3 |
Correct |
1 ms |
504 KB |
correct |
4 |
Correct |
1 ms |
336 KB |
correct |
5 |
Correct |
1 ms |
336 KB |
correct |
6 |
Correct |
1 ms |
504 KB |
correct |
7 |
Correct |
1 ms |
336 KB |
correct |
8 |
Correct |
1 ms |
336 KB |
correct |
9 |
Incorrect |
1 ms |
456 KB |
WA in grader: NO |
10 |
Halted |
0 ms |
0 KB |
- |