Submission #953359

# Submission time Handle Problem Language Result Execution time Memory
953359 2024-03-25T21:22:23 Z waldi Simurgh (IOI17_simurgh) C++17
51 / 100
89 ms 4444 KB
#include "simurgh.h"
#include <bits/stdc++.h>
#define FOR(i,p,k) for(int i=(p);i<=(k);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) (int((x).size()))
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;

vector<int> find_roads(int n, vector<int> poczatki, vector<int> konce){
	int m = ssize(poczatki);
	vector<vector<pii>> g(n);
	REP(i, m){
		int a = poczatki[i], b = konce[i];
		g[a].emplace_back(b, i);
		g[b].emplace_back(a, i);
	}
	
	vector<int> odpowiedz(m, -1);
	
	REP(wierz, n){
		vector<int> rozp;
		vector<int> bylo(n, 0), odw(n, 0);
		function<void(int)> dfs_raz = [&](int w){
			bylo[w] = odw[w] = 1;
			for(pii i : g[w]) if(i.fi!=wierz && !odw[i.fi]) rozp.emplace_back(i.se), dfs_raz(i.fi);
		};
		vector<int> odw2(n, 0);
		function<void(int)> dfs_dwa = [&](int w){
			odw2[w] = 1;
			for(pii i : g[w]) if(!odw2[i.fi]) rozp.emplace_back(i.se), dfs_dwa(i.fi);
		};
		REP(sas, n) if(sas != wierz && !bylo[sas]){
			rozp.clear();
			odw = vector<int>(n, 0);
			dfs_raz(sas);
			odw2 = odw;
			dfs_dwa(wierz);
			
			int maks = -1;
			for(pii i : g[wierz]) if(odw[i.fi] && odpowiedz[i.se] == 1){
				rozp.emplace_back(i.se);
				maks = count_common_roads(rozp);
				rozp.pop_back();
				break;
			}
			
			vector<pii> vec;
			for(pii i : g[wierz]) if(odw[i.fi] && odpowiedz[i.se] < 0){
				rozp.emplace_back(i.se);
				vec.emplace_back(i.se, count_common_roads(rozp));
				maks = max(maks, vec.back().se);
				rozp.pop_back();
			}
			for(pii i : vec) odpowiedz[i.fi] = i.se==maks;
		}
	}
	
	vector<int> ret;
	REP(i, m) if(odpowiedz[i] == 1) ret.emplace_back(i);
	return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB correct
2 Correct 0 ms 348 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 600 KB correct
7 Correct 1 ms 348 KB correct
8 Correct 0 ms 344 KB correct
9 Correct 1 ms 600 KB correct
10 Correct 0 ms 344 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 0 ms 348 KB correct
13 Correct 1 ms 348 KB correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB correct
2 Correct 0 ms 348 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 600 KB correct
7 Correct 1 ms 348 KB correct
8 Correct 0 ms 344 KB correct
9 Correct 1 ms 600 KB correct
10 Correct 0 ms 344 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 0 ms 348 KB correct
13 Correct 1 ms 348 KB correct
14 Correct 2 ms 348 KB correct
15 Correct 2 ms 500 KB correct
16 Correct 2 ms 348 KB correct
17 Correct 2 ms 348 KB correct
18 Correct 1 ms 348 KB correct
19 Correct 1 ms 348 KB correct
20 Correct 1 ms 436 KB correct
21 Correct 1 ms 348 KB correct
22 Correct 1 ms 348 KB correct
23 Correct 1 ms 348 KB correct
24 Correct 1 ms 348 KB correct
25 Correct 1 ms 348 KB correct
26 Correct 1 ms 348 KB correct
27 Correct 1 ms 348 KB correct
28 Correct 1 ms 348 KB correct
29 Correct 0 ms 348 KB correct
30 Correct 2 ms 348 KB correct
31 Correct 1 ms 348 KB correct
32 Correct 1 ms 348 KB correct
33 Correct 1 ms 348 KB correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB correct
2 Correct 0 ms 348 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 600 KB correct
7 Correct 1 ms 348 KB correct
8 Correct 0 ms 344 KB correct
9 Correct 1 ms 600 KB correct
10 Correct 0 ms 344 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 0 ms 348 KB correct
13 Correct 1 ms 348 KB correct
14 Correct 2 ms 348 KB correct
15 Correct 2 ms 500 KB correct
16 Correct 2 ms 348 KB correct
17 Correct 2 ms 348 KB correct
18 Correct 1 ms 348 KB correct
19 Correct 1 ms 348 KB correct
20 Correct 1 ms 436 KB correct
21 Correct 1 ms 348 KB correct
22 Correct 1 ms 348 KB correct
23 Correct 1 ms 348 KB correct
24 Correct 1 ms 348 KB correct
25 Correct 1 ms 348 KB correct
26 Correct 1 ms 348 KB correct
27 Correct 1 ms 348 KB correct
28 Correct 1 ms 348 KB correct
29 Correct 0 ms 348 KB correct
30 Correct 2 ms 348 KB correct
31 Correct 1 ms 348 KB correct
32 Correct 1 ms 348 KB correct
33 Correct 1 ms 348 KB correct
34 Correct 89 ms 1784 KB correct
35 Correct 81 ms 1752 KB correct
36 Correct 59 ms 1376 KB correct
37 Correct 7 ms 500 KB correct
38 Correct 83 ms 1628 KB correct
39 Correct 72 ms 1628 KB correct
40 Correct 62 ms 1524 KB correct
41 Correct 83 ms 1624 KB correct
42 Correct 82 ms 1792 KB correct
43 Correct 46 ms 1112 KB correct
44 Correct 38 ms 860 KB correct
45 Correct 43 ms 1116 KB correct
46 Correct 34 ms 856 KB correct
47 Correct 16 ms 856 KB correct
48 Correct 3 ms 348 KB correct
49 Correct 7 ms 536 KB correct
50 Correct 16 ms 508 KB correct
51 Correct 44 ms 1116 KB correct
52 Correct 37 ms 860 KB correct
53 Correct 32 ms 860 KB correct
54 Correct 46 ms 1116 KB correct
55 Correct 43 ms 1116 KB correct
56 Correct 43 ms 1116 KB correct
57 Correct 43 ms 1116 KB correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB correct
2 Correct 0 ms 348 KB correct
3 Incorrect 62 ms 4444 KB WA in grader: NO
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB correct
2 Correct 0 ms 348 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 600 KB correct
7 Correct 1 ms 348 KB correct
8 Correct 0 ms 344 KB correct
9 Correct 1 ms 600 KB correct
10 Correct 0 ms 344 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 0 ms 348 KB correct
13 Correct 1 ms 348 KB correct
14 Correct 2 ms 348 KB correct
15 Correct 2 ms 500 KB correct
16 Correct 2 ms 348 KB correct
17 Correct 2 ms 348 KB correct
18 Correct 1 ms 348 KB correct
19 Correct 1 ms 348 KB correct
20 Correct 1 ms 436 KB correct
21 Correct 1 ms 348 KB correct
22 Correct 1 ms 348 KB correct
23 Correct 1 ms 348 KB correct
24 Correct 1 ms 348 KB correct
25 Correct 1 ms 348 KB correct
26 Correct 1 ms 348 KB correct
27 Correct 1 ms 348 KB correct
28 Correct 1 ms 348 KB correct
29 Correct 0 ms 348 KB correct
30 Correct 2 ms 348 KB correct
31 Correct 1 ms 348 KB correct
32 Correct 1 ms 348 KB correct
33 Correct 1 ms 348 KB correct
34 Correct 89 ms 1784 KB correct
35 Correct 81 ms 1752 KB correct
36 Correct 59 ms 1376 KB correct
37 Correct 7 ms 500 KB correct
38 Correct 83 ms 1628 KB correct
39 Correct 72 ms 1628 KB correct
40 Correct 62 ms 1524 KB correct
41 Correct 83 ms 1624 KB correct
42 Correct 82 ms 1792 KB correct
43 Correct 46 ms 1112 KB correct
44 Correct 38 ms 860 KB correct
45 Correct 43 ms 1116 KB correct
46 Correct 34 ms 856 KB correct
47 Correct 16 ms 856 KB correct
48 Correct 3 ms 348 KB correct
49 Correct 7 ms 536 KB correct
50 Correct 16 ms 508 KB correct
51 Correct 44 ms 1116 KB correct
52 Correct 37 ms 860 KB correct
53 Correct 32 ms 860 KB correct
54 Correct 46 ms 1116 KB correct
55 Correct 43 ms 1116 KB correct
56 Correct 43 ms 1116 KB correct
57 Correct 43 ms 1116 KB correct
58 Correct 0 ms 344 KB correct
59 Correct 0 ms 348 KB correct
60 Incorrect 62 ms 4444 KB WA in grader: NO
61 Halted 0 ms 0 KB -