답안 #1065111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1065111 2024-08-18T23:01:19 Z ArthuroWich 열쇠 (IOI21_keys) C++17
37 / 100
3000 ms 55232 KB
#include "keys.h"
#include<bits/stdc++.h>
using namespace std;
int p[300005], vis[300005], reach[300005], k[300005];
vector<pair<int, int>> adj[300005];
set<int> conc[300005];
void dfs(int i, int o) {
	if (vis[i]) {
		return;
	}
	p[o]++;
	vis[i] = 1;
	reach[k[i]] = 1;
	while(!conc[k[i]].empty()) {
		int j = *conc[k[i]].begin();
		conc[k[i]].erase(conc[k[i]].begin());
		if (!vis[j]) {
			dfs(j, o);
		}
	} 
	for (auto [j, c] : adj[i]) {
		if (reach[c]) {
			dfs(j, o);
		} else if (!vis[j]) {
			conc[c].insert(j);
		}
	}
}
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
	int n = r.size(), m = c.size();
	for (int i = 0; i < n; i++) {
		k[i] = r[i];
	}
	set<int> e;
	for (int i = 0; i < m; i++) {
		adj[u[i]].push_back({v[i], c[i]});
		adj[v[i]].push_back({u[i], c[i]});
		e.insert(c[i]);
	}
	for (int i = 0; i < n; i++) {
		dfs(i, i);
		for (int j = 0; j < n; j++) {
			vis[j] = 0;
		}
		for (int j : e) {
			reach[j] = 0;
			conc[j].clear();
		}
	}
	int mn = p[0];
	for (int i = 1; i < n; i++) {
		mn = min(mn, p[i]);
	}
	vector<int> ans(n, 0);
	for (int i = 0; i < n; i++) {
		if (p[i] == mn) {
			ans[i] = 1;
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 21592 KB Output is correct
2 Correct 9 ms 21496 KB Output is correct
3 Correct 10 ms 21384 KB Output is correct
4 Correct 9 ms 21484 KB Output is correct
5 Correct 9 ms 21596 KB Output is correct
6 Correct 10 ms 21596 KB Output is correct
7 Correct 9 ms 21504 KB Output is correct
8 Correct 9 ms 21844 KB Output is correct
9 Correct 10 ms 21592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 21592 KB Output is correct
2 Correct 9 ms 21496 KB Output is correct
3 Correct 10 ms 21384 KB Output is correct
4 Correct 9 ms 21484 KB Output is correct
5 Correct 9 ms 21596 KB Output is correct
6 Correct 10 ms 21596 KB Output is correct
7 Correct 9 ms 21504 KB Output is correct
8 Correct 9 ms 21844 KB Output is correct
9 Correct 10 ms 21592 KB Output is correct
10 Correct 11 ms 21592 KB Output is correct
11 Correct 10 ms 21452 KB Output is correct
12 Correct 10 ms 21608 KB Output is correct
13 Correct 10 ms 21592 KB Output is correct
14 Correct 10 ms 21596 KB Output is correct
15 Correct 11 ms 21464 KB Output is correct
16 Correct 9 ms 21596 KB Output is correct
17 Correct 10 ms 21596 KB Output is correct
18 Correct 10 ms 21600 KB Output is correct
19 Correct 9 ms 21596 KB Output is correct
20 Correct 10 ms 21596 KB Output is correct
21 Correct 10 ms 21588 KB Output is correct
22 Correct 9 ms 21596 KB Output is correct
23 Correct 10 ms 21596 KB Output is correct
24 Correct 10 ms 21536 KB Output is correct
25 Correct 10 ms 21592 KB Output is correct
26 Correct 13 ms 21596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 21592 KB Output is correct
2 Correct 9 ms 21496 KB Output is correct
3 Correct 10 ms 21384 KB Output is correct
4 Correct 9 ms 21484 KB Output is correct
5 Correct 9 ms 21596 KB Output is correct
6 Correct 10 ms 21596 KB Output is correct
7 Correct 9 ms 21504 KB Output is correct
8 Correct 9 ms 21844 KB Output is correct
9 Correct 10 ms 21592 KB Output is correct
10 Correct 11 ms 21592 KB Output is correct
11 Correct 10 ms 21452 KB Output is correct
12 Correct 10 ms 21608 KB Output is correct
13 Correct 10 ms 21592 KB Output is correct
14 Correct 10 ms 21596 KB Output is correct
15 Correct 11 ms 21464 KB Output is correct
16 Correct 9 ms 21596 KB Output is correct
17 Correct 10 ms 21596 KB Output is correct
18 Correct 10 ms 21600 KB Output is correct
19 Correct 9 ms 21596 KB Output is correct
20 Correct 10 ms 21596 KB Output is correct
21 Correct 10 ms 21588 KB Output is correct
22 Correct 9 ms 21596 KB Output is correct
23 Correct 10 ms 21596 KB Output is correct
24 Correct 10 ms 21536 KB Output is correct
25 Correct 10 ms 21592 KB Output is correct
26 Correct 13 ms 21596 KB Output is correct
27 Correct 64 ms 22012 KB Output is correct
28 Correct 64 ms 21848 KB Output is correct
29 Correct 70 ms 22032 KB Output is correct
30 Correct 36 ms 21596 KB Output is correct
31 Correct 10 ms 21596 KB Output is correct
32 Correct 10 ms 21552 KB Output is correct
33 Correct 9 ms 21596 KB Output is correct
34 Correct 21 ms 21592 KB Output is correct
35 Correct 33 ms 21592 KB Output is correct
36 Correct 121 ms 21972 KB Output is correct
37 Correct 113 ms 21984 KB Output is correct
38 Correct 123 ms 21848 KB Output is correct
39 Correct 125 ms 21848 KB Output is correct
40 Correct 12 ms 21592 KB Output is correct
41 Correct 33 ms 21844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 21592 KB Output is correct
2 Correct 9 ms 21496 KB Output is correct
3 Correct 10 ms 21384 KB Output is correct
4 Correct 9 ms 21484 KB Output is correct
5 Correct 9 ms 21596 KB Output is correct
6 Correct 10 ms 21596 KB Output is correct
7 Correct 9 ms 21504 KB Output is correct
8 Correct 9 ms 21844 KB Output is correct
9 Correct 10 ms 21592 KB Output is correct
10 Execution timed out 3048 ms 55232 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 21592 KB Output is correct
2 Correct 9 ms 21496 KB Output is correct
3 Correct 10 ms 21384 KB Output is correct
4 Correct 9 ms 21484 KB Output is correct
5 Correct 9 ms 21596 KB Output is correct
6 Correct 10 ms 21596 KB Output is correct
7 Correct 9 ms 21504 KB Output is correct
8 Correct 9 ms 21844 KB Output is correct
9 Correct 10 ms 21592 KB Output is correct
10 Correct 11 ms 21592 KB Output is correct
11 Correct 10 ms 21452 KB Output is correct
12 Correct 10 ms 21608 KB Output is correct
13 Correct 10 ms 21592 KB Output is correct
14 Correct 10 ms 21596 KB Output is correct
15 Correct 11 ms 21464 KB Output is correct
16 Correct 9 ms 21596 KB Output is correct
17 Correct 10 ms 21596 KB Output is correct
18 Correct 10 ms 21600 KB Output is correct
19 Correct 9 ms 21596 KB Output is correct
20 Correct 10 ms 21596 KB Output is correct
21 Correct 10 ms 21588 KB Output is correct
22 Correct 9 ms 21596 KB Output is correct
23 Correct 10 ms 21596 KB Output is correct
24 Correct 10 ms 21536 KB Output is correct
25 Correct 10 ms 21592 KB Output is correct
26 Correct 13 ms 21596 KB Output is correct
27 Correct 64 ms 22012 KB Output is correct
28 Correct 64 ms 21848 KB Output is correct
29 Correct 70 ms 22032 KB Output is correct
30 Correct 36 ms 21596 KB Output is correct
31 Correct 10 ms 21596 KB Output is correct
32 Correct 10 ms 21552 KB Output is correct
33 Correct 9 ms 21596 KB Output is correct
34 Correct 21 ms 21592 KB Output is correct
35 Correct 33 ms 21592 KB Output is correct
36 Correct 121 ms 21972 KB Output is correct
37 Correct 113 ms 21984 KB Output is correct
38 Correct 123 ms 21848 KB Output is correct
39 Correct 125 ms 21848 KB Output is correct
40 Correct 12 ms 21592 KB Output is correct
41 Correct 33 ms 21844 KB Output is correct
42 Execution timed out 3048 ms 55232 KB Time limit exceeded
43 Halted 0 ms 0 KB -