# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
626693 |
2022-08-11T16:16:10 Z |
Mounir |
Simurgh (IOI17_simurgh) |
C++14 |
|
169 ms |
9800 KB |
#include "simurgh.h"
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define x first
#define y second
using namespace std;
const int N = 2000;
int ens[N];
int getEns(int noeud){
if (ens[noeud] != noeud)
ens[noeud] = getEns(ens[noeud]);
return ens[noeud];
}
int nNoeuds;
set<int> royales;
vector<pii> aretes;
set<int> sortantes[N];
void findRoyales(int supprime){
for (int noeud = 0; noeud < nNoeuds; ++noeud)
ens[noeud] = noeud;
vector<int> choisies;
int id = -1;
vector<vector<int>> liens;
vector<int> icc;
for (pii arete : aretes){
id++;
if (arete.x == supprime || arete.y == supprime) continue;
if (getEns(arete.x) != getEns(arete.y)){
ens[getEns(arete.y)] = getEns(arete.x);
choisies.pb(id);
}
}
for (int sortante : sortantes[supprime]){
int autre = aretes[sortante].x;
if (autre == supprime)
autre = aretes[sortante].y;
bool add = false;
for (int iLien = 0; iLien < sz(liens); ++iLien){
if (icc[iLien] == getEns(autre)){
add = true;
liens[iLien].pb(sortante);
}
}
if (!add) {
icc.pb(getEns(autre));
liens.pb({sortante});
}
}
for (int iLien = 0; iLien < sz(liens); ++iLien){
vector<int> total = choisies;
for (int iAutre = 0; iAutre < sz(liens); ++iAutre){
if (iAutre != iLien)
total.pb(liens[iAutre][0]);
}
vector<pii> resRoute;
bool royMis = false;
for (int lien : liens[iLien]) {
total.pb(lien);
int autre = aretes[lien].x;
if (autre == supprime)
autre = aretes[lien].y;
if (autre < supprime || !royales.count(lien) || !royMis) {
royMis |= royales.count(lien);
resRoute.pb({count_common_roads(total), lien});
}
total.pop_back();
}
sort(all(resRoute));
/* cout << "res route" << endl;
for (pii a : resRoute)
cout << a.x << " " << a.y << endl;*/
int maxi = resRoute.back().x;
while (!resRoute.empty() && resRoute.back().x == maxi){
royales.insert(resRoute.back().y);
resRoute.pop_back();
}
}
}
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
nNoeuds = n;
for (int i = 0; i < sz(u); ++i) {
aretes.pb(make_pair(u[i], v[i]));
sortantes[u[i]].insert(i);
sortantes[v[i]].insert(i);
}
for (int sup = 0; sup < n; ++sup)
findRoyales(sup);
vector<int> ans;
for (int e : royales)
ans.pb(e);
/*
cout << "royales" << endl;
for (int e : ans)
cout << e << " ";
cout << endl;*/
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
correct |
2 |
Correct |
0 ms |
340 KB |
correct |
3 |
Correct |
0 ms |
340 KB |
correct |
4 |
Correct |
1 ms |
340 KB |
correct |
5 |
Correct |
1 ms |
340 KB |
correct |
6 |
Correct |
1 ms |
340 KB |
correct |
7 |
Correct |
0 ms |
340 KB |
correct |
8 |
Correct |
0 ms |
340 KB |
correct |
9 |
Correct |
0 ms |
340 KB |
correct |
10 |
Correct |
0 ms |
340 KB |
correct |
11 |
Correct |
0 ms |
340 KB |
correct |
12 |
Correct |
0 ms |
340 KB |
correct |
13 |
Correct |
0 ms |
340 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
correct |
2 |
Correct |
0 ms |
340 KB |
correct |
3 |
Correct |
0 ms |
340 KB |
correct |
4 |
Correct |
1 ms |
340 KB |
correct |
5 |
Correct |
1 ms |
340 KB |
correct |
6 |
Correct |
1 ms |
340 KB |
correct |
7 |
Correct |
0 ms |
340 KB |
correct |
8 |
Correct |
0 ms |
340 KB |
correct |
9 |
Correct |
0 ms |
340 KB |
correct |
10 |
Correct |
0 ms |
340 KB |
correct |
11 |
Correct |
0 ms |
340 KB |
correct |
12 |
Correct |
0 ms |
340 KB |
correct |
13 |
Correct |
0 ms |
340 KB |
correct |
14 |
Correct |
4 ms |
556 KB |
correct |
15 |
Correct |
4 ms |
468 KB |
correct |
16 |
Correct |
4 ms |
468 KB |
correct |
17 |
Correct |
3 ms |
468 KB |
correct |
18 |
Correct |
2 ms |
340 KB |
correct |
19 |
Correct |
3 ms |
468 KB |
correct |
20 |
Correct |
3 ms |
468 KB |
correct |
21 |
Correct |
3 ms |
468 KB |
correct |
22 |
Correct |
2 ms |
468 KB |
correct |
23 |
Correct |
2 ms |
468 KB |
correct |
24 |
Correct |
2 ms |
468 KB |
correct |
25 |
Correct |
1 ms |
340 KB |
correct |
26 |
Correct |
2 ms |
468 KB |
correct |
27 |
Correct |
3 ms |
596 KB |
correct |
28 |
Correct |
1 ms |
340 KB |
correct |
29 |
Correct |
1 ms |
340 KB |
correct |
30 |
Correct |
2 ms |
468 KB |
correct |
31 |
Correct |
2 ms |
468 KB |
correct |
32 |
Correct |
2 ms |
468 KB |
correct |
33 |
Correct |
2 ms |
468 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
correct |
2 |
Correct |
0 ms |
340 KB |
correct |
3 |
Correct |
0 ms |
340 KB |
correct |
4 |
Correct |
1 ms |
340 KB |
correct |
5 |
Correct |
1 ms |
340 KB |
correct |
6 |
Correct |
1 ms |
340 KB |
correct |
7 |
Correct |
0 ms |
340 KB |
correct |
8 |
Correct |
0 ms |
340 KB |
correct |
9 |
Correct |
0 ms |
340 KB |
correct |
10 |
Correct |
0 ms |
340 KB |
correct |
11 |
Correct |
0 ms |
340 KB |
correct |
12 |
Correct |
0 ms |
340 KB |
correct |
13 |
Correct |
0 ms |
340 KB |
correct |
14 |
Correct |
4 ms |
556 KB |
correct |
15 |
Correct |
4 ms |
468 KB |
correct |
16 |
Correct |
4 ms |
468 KB |
correct |
17 |
Correct |
3 ms |
468 KB |
correct |
18 |
Correct |
2 ms |
340 KB |
correct |
19 |
Correct |
3 ms |
468 KB |
correct |
20 |
Correct |
3 ms |
468 KB |
correct |
21 |
Correct |
3 ms |
468 KB |
correct |
22 |
Correct |
2 ms |
468 KB |
correct |
23 |
Correct |
2 ms |
468 KB |
correct |
24 |
Correct |
2 ms |
468 KB |
correct |
25 |
Correct |
1 ms |
340 KB |
correct |
26 |
Correct |
2 ms |
468 KB |
correct |
27 |
Correct |
3 ms |
596 KB |
correct |
28 |
Correct |
1 ms |
340 KB |
correct |
29 |
Correct |
1 ms |
340 KB |
correct |
30 |
Correct |
2 ms |
468 KB |
correct |
31 |
Correct |
2 ms |
468 KB |
correct |
32 |
Correct |
2 ms |
468 KB |
correct |
33 |
Correct |
2 ms |
468 KB |
correct |
34 |
Incorrect |
167 ms |
3792 KB |
WA in grader: NO |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
correct |
2 |
Correct |
1 ms |
292 KB |
correct |
3 |
Incorrect |
169 ms |
9800 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
correct |
2 |
Correct |
0 ms |
340 KB |
correct |
3 |
Correct |
0 ms |
340 KB |
correct |
4 |
Correct |
1 ms |
340 KB |
correct |
5 |
Correct |
1 ms |
340 KB |
correct |
6 |
Correct |
1 ms |
340 KB |
correct |
7 |
Correct |
0 ms |
340 KB |
correct |
8 |
Correct |
0 ms |
340 KB |
correct |
9 |
Correct |
0 ms |
340 KB |
correct |
10 |
Correct |
0 ms |
340 KB |
correct |
11 |
Correct |
0 ms |
340 KB |
correct |
12 |
Correct |
0 ms |
340 KB |
correct |
13 |
Correct |
0 ms |
340 KB |
correct |
14 |
Correct |
4 ms |
556 KB |
correct |
15 |
Correct |
4 ms |
468 KB |
correct |
16 |
Correct |
4 ms |
468 KB |
correct |
17 |
Correct |
3 ms |
468 KB |
correct |
18 |
Correct |
2 ms |
340 KB |
correct |
19 |
Correct |
3 ms |
468 KB |
correct |
20 |
Correct |
3 ms |
468 KB |
correct |
21 |
Correct |
3 ms |
468 KB |
correct |
22 |
Correct |
2 ms |
468 KB |
correct |
23 |
Correct |
2 ms |
468 KB |
correct |
24 |
Correct |
2 ms |
468 KB |
correct |
25 |
Correct |
1 ms |
340 KB |
correct |
26 |
Correct |
2 ms |
468 KB |
correct |
27 |
Correct |
3 ms |
596 KB |
correct |
28 |
Correct |
1 ms |
340 KB |
correct |
29 |
Correct |
1 ms |
340 KB |
correct |
30 |
Correct |
2 ms |
468 KB |
correct |
31 |
Correct |
2 ms |
468 KB |
correct |
32 |
Correct |
2 ms |
468 KB |
correct |
33 |
Correct |
2 ms |
468 KB |
correct |
34 |
Incorrect |
167 ms |
3792 KB |
WA in grader: NO |
35 |
Halted |
0 ms |
0 KB |
- |