# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
626678 |
2022-08-11T15:59:21 Z |
Mounir |
Simurgh (IOI17_simurgh) |
C++14 |
|
185 ms |
9796 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, M = 3e5;
int ens[N];
bool check[M];
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){
/*cout << "deja trouvee " << supprime << endl;
for (int royale : royales)
cout << royale << " ";
cout << endl;*/
for (int noeud = 0; noeud < nNoeuds; ++noeud)
ens[noeud] = noeud;
vector<int> choisies;
for (int royale : royales){
ens[getEns(aretes[royale].x)] = getEns(aretes[royale].y);
choisies.pb(royale);
}
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);
}
}
if (ens[supprime] != supprime || getEns((supprime + 1)%nNoeuds) == supprime) return;
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;
for (int lien : liens[iLien]) {
total.pb(lien);
/*cout << "guess" << endl;
for (int c : total)
cout << c << " ";
cout << endl;*/
resRoute.pb({count_common_roads(total), lien});
total.pop_back();
}
sort(all(resRoute));
int maxi = resRoute.back().x;
while (!resRoute.empty() && resRoute.back().x == maxi){
royales.insert(resRoute.back().y);
resRoute.pop_back();
}
}
for (int sortante : sortantes[supprime]){
int autre = aretes[sortante].x;
if (autre == supprime)
autre = aretes[supprime].y;
sortantes[autre].erase(sortante);
}
}
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 |
Runtime error |
1 ms |
596 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
596 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
596 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
correct |
2 |
Correct |
1 ms |
340 KB |
correct |
3 |
Incorrect |
185 ms |
9796 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
596 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |