답안 #559688

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
559688 2022-05-10T12:01:21 Z nonsensenonsense1 Simurgh (IOI17_simurgh) C++17
51 / 100
141 ms 4084 KB
#include "simurgh.h"
#include <cstdio>
#include <cstring>
#include <vector>

const int N = 500;
const int E = N * N;
std::vector<std::pair<int, int> > g[N];
int u[N], val[N];
bool know[E], ans[E];

std::vector<int> edg;
int it;
void dfs(int v) {
	u[v] = it;
	for (int i = 0; i < (int)g[v].size(); ++i) if (!u[g[v][i].first]) {
		edg.push_back(g[v][i].second);
		dfs(g[v][i].first);
	}
}

std::vector<int> find_roads(int n, std::vector<int> u_, std::vector<int> v_) {
	for (int i = 0; i < (int)u_.size(); ++i) {
		g[u_[i]].push_back(std::make_pair(v_[i], i));
		g[v_[i]].push_back(std::make_pair(u_[i], i));
	}
	for (int i = 0; i < n; ++i) {
		memset(u, 0, n << 2);
		u[i] = 1;
		it = 0;
		for (int j = 0; j < n; ++j) if (!u[j]) {
			++it;
			dfs(j);
		}
		for (int iit = 1; iit <= it; ++iit) {
			for (int j = 0;; ++j) if (u[g[i][j].first] == iit) {
				edg.push_back(g[i][j].second);
				break;
			}
		}
		for (int iit = 1; iit <= it; ++iit) {
			int fi = edg[n - 2 - it + iit];
			edg.erase(edg.begin() + n - 2 - it + iit);
			int mn = ~(1 << 31), mx = 0, real = -1;
			bool askonce = 0;
			for (int j = 0; j < (int)g[i].size(); ++j) if (u[g[i][j].first] == iit) {
				if (!know[g[i][j].second] || !askonce) {
					edg.push_back(g[i][j].second);
					val[j] = count_common_roads(edg);
					if (know[g[i][j].second]) {
						real = val[j] - ans[g[i][j].second];
						askonce = 1;
					}
					mn = std::min(mn, val[j]);
					mx = std::max(mx, val[j]);
					edg.pop_back();
				}
			}
			if (real == -1) real = mn - (mn == mx);
			for (int j = 0; j < (int)g[i].size(); ++j) if (u[g[i][j].first] == iit && !know[g[i][j].second]) {
				know[g[i][j].second] = 1;
				ans[g[i][j].second] = val[j] != real;
			}
			edg.insert(edg.begin() + n - 2 - it + iit, fi);
		}
		edg.clear();
	}
	std::vector<int> ret;
	for (int i = 0; i < (int)u_.size(); ++i) if (ans[i]) ret.push_back(i);
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB correct
2 Correct 1 ms 304 KB correct
3 Correct 1 ms 308 KB correct
4 Correct 1 ms 212 KB correct
5 Correct 0 ms 212 KB correct
6 Correct 0 ms 300 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 0 ms 212 KB correct
9 Correct 1 ms 212 KB correct
10 Correct 1 ms 212 KB correct
11 Correct 0 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 1 ms 304 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB correct
2 Correct 1 ms 304 KB correct
3 Correct 1 ms 308 KB correct
4 Correct 1 ms 212 KB correct
5 Correct 0 ms 212 KB correct
6 Correct 0 ms 300 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 0 ms 212 KB correct
9 Correct 1 ms 212 KB correct
10 Correct 1 ms 212 KB correct
11 Correct 0 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 1 ms 304 KB correct
14 Correct 2 ms 340 KB correct
15 Correct 2 ms 340 KB correct
16 Correct 3 ms 340 KB correct
17 Correct 2 ms 500 KB correct
18 Correct 1 ms 292 KB correct
19 Correct 2 ms 304 KB correct
20 Correct 2 ms 340 KB correct
21 Correct 2 ms 340 KB correct
22 Correct 2 ms 340 KB correct
23 Correct 1 ms 340 KB correct
24 Correct 2 ms 308 KB correct
25 Correct 1 ms 212 KB correct
26 Correct 2 ms 340 KB correct
27 Correct 1 ms 340 KB correct
28 Correct 1 ms 212 KB correct
29 Correct 1 ms 212 KB correct
30 Correct 1 ms 340 KB correct
31 Correct 1 ms 340 KB correct
32 Correct 1 ms 340 KB correct
33 Correct 1 ms 300 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB correct
2 Correct 1 ms 304 KB correct
3 Correct 1 ms 308 KB correct
4 Correct 1 ms 212 KB correct
5 Correct 0 ms 212 KB correct
6 Correct 0 ms 300 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 0 ms 212 KB correct
9 Correct 1 ms 212 KB correct
10 Correct 1 ms 212 KB correct
11 Correct 0 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 1 ms 304 KB correct
14 Correct 2 ms 340 KB correct
15 Correct 2 ms 340 KB correct
16 Correct 3 ms 340 KB correct
17 Correct 2 ms 500 KB correct
18 Correct 1 ms 292 KB correct
19 Correct 2 ms 304 KB correct
20 Correct 2 ms 340 KB correct
21 Correct 2 ms 340 KB correct
22 Correct 2 ms 340 KB correct
23 Correct 1 ms 340 KB correct
24 Correct 2 ms 308 KB correct
25 Correct 1 ms 212 KB correct
26 Correct 2 ms 340 KB correct
27 Correct 1 ms 340 KB correct
28 Correct 1 ms 212 KB correct
29 Correct 1 ms 212 KB correct
30 Correct 1 ms 340 KB correct
31 Correct 1 ms 340 KB correct
32 Correct 1 ms 340 KB correct
33 Correct 1 ms 300 KB correct
34 Correct 141 ms 1588 KB correct
35 Correct 127 ms 1492 KB correct
36 Correct 92 ms 1340 KB correct
37 Correct 10 ms 308 KB correct
38 Correct 137 ms 1612 KB correct
39 Correct 128 ms 1492 KB correct
40 Correct 98 ms 1364 KB correct
41 Correct 134 ms 1492 KB correct
42 Correct 135 ms 1580 KB correct
43 Correct 74 ms 1108 KB correct
44 Correct 60 ms 852 KB correct
45 Correct 72 ms 936 KB correct
46 Correct 58 ms 724 KB correct
47 Correct 26 ms 468 KB correct
48 Correct 4 ms 300 KB correct
49 Correct 9 ms 308 KB correct
50 Correct 25 ms 468 KB correct
51 Correct 69 ms 952 KB correct
52 Correct 60 ms 880 KB correct
53 Correct 52 ms 724 KB correct
54 Correct 72 ms 1108 KB correct
55 Correct 69 ms 948 KB correct
56 Correct 71 ms 940 KB correct
57 Correct 79 ms 960 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB correct
2 Correct 0 ms 212 KB correct
3 Incorrect 107 ms 4084 KB WA in grader: NO
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB correct
2 Correct 1 ms 304 KB correct
3 Correct 1 ms 308 KB correct
4 Correct 1 ms 212 KB correct
5 Correct 0 ms 212 KB correct
6 Correct 0 ms 300 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 0 ms 212 KB correct
9 Correct 1 ms 212 KB correct
10 Correct 1 ms 212 KB correct
11 Correct 0 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 1 ms 304 KB correct
14 Correct 2 ms 340 KB correct
15 Correct 2 ms 340 KB correct
16 Correct 3 ms 340 KB correct
17 Correct 2 ms 500 KB correct
18 Correct 1 ms 292 KB correct
19 Correct 2 ms 304 KB correct
20 Correct 2 ms 340 KB correct
21 Correct 2 ms 340 KB correct
22 Correct 2 ms 340 KB correct
23 Correct 1 ms 340 KB correct
24 Correct 2 ms 308 KB correct
25 Correct 1 ms 212 KB correct
26 Correct 2 ms 340 KB correct
27 Correct 1 ms 340 KB correct
28 Correct 1 ms 212 KB correct
29 Correct 1 ms 212 KB correct
30 Correct 1 ms 340 KB correct
31 Correct 1 ms 340 KB correct
32 Correct 1 ms 340 KB correct
33 Correct 1 ms 300 KB correct
34 Correct 141 ms 1588 KB correct
35 Correct 127 ms 1492 KB correct
36 Correct 92 ms 1340 KB correct
37 Correct 10 ms 308 KB correct
38 Correct 137 ms 1612 KB correct
39 Correct 128 ms 1492 KB correct
40 Correct 98 ms 1364 KB correct
41 Correct 134 ms 1492 KB correct
42 Correct 135 ms 1580 KB correct
43 Correct 74 ms 1108 KB correct
44 Correct 60 ms 852 KB correct
45 Correct 72 ms 936 KB correct
46 Correct 58 ms 724 KB correct
47 Correct 26 ms 468 KB correct
48 Correct 4 ms 300 KB correct
49 Correct 9 ms 308 KB correct
50 Correct 25 ms 468 KB correct
51 Correct 69 ms 952 KB correct
52 Correct 60 ms 880 KB correct
53 Correct 52 ms 724 KB correct
54 Correct 72 ms 1108 KB correct
55 Correct 69 ms 948 KB correct
56 Correct 71 ms 940 KB correct
57 Correct 79 ms 960 KB correct
58 Correct 0 ms 212 KB correct
59 Correct 0 ms 212 KB correct
60 Incorrect 107 ms 4084 KB WA in grader: NO
61 Halted 0 ms 0 KB -