Submission #626698

# Submission time Handle Problem Language Result Execution time Memory
626698 2022-08-11T16:18:48 Z Mounir Simurgh (IOI17_simurgh) C++14
51 / 100
175 ms 9716 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 1 ms 340 KB correct
4 Correct 0 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 1 ms 340 KB correct
11 Correct 1 ms 340 KB correct
12 Correct 1 ms 340 KB correct
13 Correct 1 ms 400 KB correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB correct
2 Correct 0 ms 340 KB correct
3 Correct 1 ms 340 KB correct
4 Correct 0 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 1 ms 340 KB correct
11 Correct 1 ms 340 KB correct
12 Correct 1 ms 340 KB correct
13 Correct 1 ms 400 KB correct
14 Correct 3 ms 468 KB correct
15 Correct 3 ms 468 KB correct
16 Correct 2 ms 468 KB correct
17 Correct 2 ms 468 KB correct
18 Correct 1 ms 340 KB correct
19 Correct 2 ms 468 KB correct
20 Correct 3 ms 468 KB correct
21 Correct 2 ms 468 KB correct
22 Correct 2 ms 468 KB correct
23 Correct 1 ms 476 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 2 ms 468 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 388 KB correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB correct
2 Correct 0 ms 340 KB correct
3 Correct 1 ms 340 KB correct
4 Correct 0 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 1 ms 340 KB correct
11 Correct 1 ms 340 KB correct
12 Correct 1 ms 340 KB correct
13 Correct 1 ms 400 KB correct
14 Correct 3 ms 468 KB correct
15 Correct 3 ms 468 KB correct
16 Correct 2 ms 468 KB correct
17 Correct 2 ms 468 KB correct
18 Correct 1 ms 340 KB correct
19 Correct 2 ms 468 KB correct
20 Correct 3 ms 468 KB correct
21 Correct 2 ms 468 KB correct
22 Correct 2 ms 468 KB correct
23 Correct 1 ms 476 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 2 ms 468 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 388 KB correct
34 Correct 174 ms 3792 KB correct
35 Correct 175 ms 3872 KB correct
36 Correct 114 ms 2772 KB correct
37 Correct 11 ms 576 KB correct
38 Correct 168 ms 3952 KB correct
39 Correct 150 ms 3436 KB correct
40 Correct 116 ms 2768 KB correct
41 Correct 171 ms 3920 KB correct
42 Correct 171 ms 4096 KB correct
43 Correct 87 ms 2260 KB correct
44 Correct 74 ms 1908 KB correct
45 Correct 86 ms 2116 KB correct
46 Correct 65 ms 1740 KB correct
47 Correct 29 ms 1004 KB correct
48 Correct 5 ms 468 KB correct
49 Correct 11 ms 596 KB correct
50 Correct 29 ms 1004 KB correct
51 Correct 86 ms 2132 KB correct
52 Correct 74 ms 1956 KB correct
53 Correct 65 ms 1748 KB correct
54 Correct 90 ms 2300 KB correct
55 Correct 80 ms 2132 KB correct
56 Correct 79 ms 2208 KB correct
57 Correct 79 ms 2232 KB correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB correct
2 Correct 1 ms 340 KB correct
3 Incorrect 152 ms 9716 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 1 ms 340 KB correct
4 Correct 0 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 1 ms 340 KB correct
11 Correct 1 ms 340 KB correct
12 Correct 1 ms 340 KB correct
13 Correct 1 ms 400 KB correct
14 Correct 3 ms 468 KB correct
15 Correct 3 ms 468 KB correct
16 Correct 2 ms 468 KB correct
17 Correct 2 ms 468 KB correct
18 Correct 1 ms 340 KB correct
19 Correct 2 ms 468 KB correct
20 Correct 3 ms 468 KB correct
21 Correct 2 ms 468 KB correct
22 Correct 2 ms 468 KB correct
23 Correct 1 ms 476 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 2 ms 468 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 388 KB correct
34 Correct 174 ms 3792 KB correct
35 Correct 175 ms 3872 KB correct
36 Correct 114 ms 2772 KB correct
37 Correct 11 ms 576 KB correct
38 Correct 168 ms 3952 KB correct
39 Correct 150 ms 3436 KB correct
40 Correct 116 ms 2768 KB correct
41 Correct 171 ms 3920 KB correct
42 Correct 171 ms 4096 KB correct
43 Correct 87 ms 2260 KB correct
44 Correct 74 ms 1908 KB correct
45 Correct 86 ms 2116 KB correct
46 Correct 65 ms 1740 KB correct
47 Correct 29 ms 1004 KB correct
48 Correct 5 ms 468 KB correct
49 Correct 11 ms 596 KB correct
50 Correct 29 ms 1004 KB correct
51 Correct 86 ms 2132 KB correct
52 Correct 74 ms 1956 KB correct
53 Correct 65 ms 1748 KB correct
54 Correct 90 ms 2300 KB correct
55 Correct 80 ms 2132 KB correct
56 Correct 79 ms 2208 KB correct
57 Correct 79 ms 2232 KB correct
58 Correct 0 ms 340 KB correct
59 Correct 1 ms 340 KB correct
60 Incorrect 152 ms 9716 KB WA in grader: NO
61 Halted 0 ms 0 KB -