#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 10;
struct EDGE{
int to , id;
};
int n , m;
vector <EDGE> adj[N];
vector <int> r;
bool marked[N] , dead[N];
int Find_good(int v)
{
marked[v] = true;
for(auto u : adj[v]) if(!marked[u.to])
return Find_good(u.to);
return v;
}
void Dfs(int v)
{
marked[v] = true;
for(auto u : adj[v]) if(!marked[u.to] && !dead[u.to])
{
r.push_back(u.id);
Dfs(u.to);
}
}
vector<int> find_roads(int nn, vector<int> u, vector<int> v) {
n = nn;
m = u.size();
for(int i = 0 ; i < m ; i++)
{
adj[u[i]].push_back({v[i] , i});
adj[v[i]].push_back({u[i] , i});
}
int star = Find_good(0);
vector <int> cand;
dead[star] = true;
cand.push_back(star);
vector <int> cor;
//cout << "STAR " << star << endl;
while(!cand.empty())
{
int mx = 0;
vector <EDGE> add;
r = cor;
for(int i = 0 ; i < n ; i++)
marked[i] = false;
for(int i = 0 ; i < n ; i++) if(!dead[i])
{
Dfs(i);
break;
}
for(auto v : cand) for(auto u : adj[v]) if(!dead[u.to])
{
r.push_back(u.id);
//for(auto u : r)
// cout << u << " ";
//cout << " ? " << endl;
int now = count_common_roads(r);
//cout << now << endl;
if(now > mx)
{
mx = now;
add.clear();
}
if(now == mx)
add.push_back(u);
r.pop_back();
}
cand.clear();
for(auto u : add)
{
cor.push_back(u.id);
dead[u.to] = true;
cand.push_back(u.to);
}
}
return cor;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
correct |
2 |
Correct |
0 ms |
344 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 |
0 ms |
348 KB |
correct |
7 |
Correct |
0 ms |
348 KB |
correct |
8 |
Correct |
0 ms |
348 KB |
correct |
9 |
Incorrect |
1 ms |
348 KB |
WA in grader: NO |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
correct |
2 |
Correct |
0 ms |
344 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 |
0 ms |
348 KB |
correct |
7 |
Correct |
0 ms |
348 KB |
correct |
8 |
Correct |
0 ms |
348 KB |
correct |
9 |
Incorrect |
1 ms |
348 KB |
WA in grader: NO |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
correct |
2 |
Correct |
0 ms |
344 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 |
0 ms |
348 KB |
correct |
7 |
Correct |
0 ms |
348 KB |
correct |
8 |
Correct |
0 ms |
348 KB |
correct |
9 |
Incorrect |
1 ms |
348 KB |
WA in grader: NO |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
correct |
2 |
Correct |
0 ms |
412 KB |
correct |
3 |
Incorrect |
61 ms |
3972 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
correct |
2 |
Correct |
0 ms |
344 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 |
0 ms |
348 KB |
correct |
7 |
Correct |
0 ms |
348 KB |
correct |
8 |
Correct |
0 ms |
348 KB |
correct |
9 |
Incorrect |
1 ms |
348 KB |
WA in grader: NO |
10 |
Halted |
0 ms |
0 KB |
- |