답안 #532079

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532079 2022-03-02T05:17:52 Z rk42745417 Unique Cities (JOI19_ho_t5) C++17
4 / 100
2000 ms 18344 KB
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = ll(4e15) + ll(2e15);
const double EPS = 1e-9;
static int LamyIsCute = []() {
	EmiliaMyWife
	return 48763;
}();

signed main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> edge(n + 1);
	for(int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	vector<int> col(n + 1);
	for(int i = 1; i <= n; i++)
		cin >> col[i];
	vector<vector<int>> has(n + 1);
	vector<bool> owo(m + 1);
	function<void(int, int, int)> dfs = [&](int u, int p, int d) {
		for(int v : edge[u])
			if(v != p)
				dfs(v, u, d + 1);
		has[d].push_back(col[u]);
	};
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= n; j++)
			has[j].clear();
		for(int j = 0; j <= m; j++)
			owo[j] = false;
		dfs(i, i, 0);
		int res = 0;
		for(int j = 1; j <= n; j++)
			if(has[j].size() == 1 && !owo[has[j][0]])
				res++, owo[has[j][0]] = true;
		cout << res << '\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 85 ms 544 KB Output is correct
3 Correct 28 ms 512 KB Output is correct
4 Correct 89 ms 708 KB Output is correct
5 Correct 90 ms 544 KB Output is correct
6 Correct 118 ms 716 KB Output is correct
7 Correct 125 ms 700 KB Output is correct
8 Correct 109 ms 524 KB Output is correct
9 Correct 97 ms 568 KB Output is correct
10 Correct 110 ms 676 KB Output is correct
11 Correct 96 ms 580 KB Output is correct
12 Correct 73 ms 660 KB Output is correct
13 Correct 118 ms 756 KB Output is correct
14 Correct 99 ms 1348 KB Output is correct
15 Correct 101 ms 1220 KB Output is correct
16 Correct 71 ms 520 KB Output is correct
17 Correct 106 ms 3320 KB Output is correct
18 Correct 103 ms 1632 KB Output is correct
19 Correct 97 ms 528 KB Output is correct
20 Correct 135 ms 764 KB Output is correct
21 Correct 117 ms 776 KB Output is correct
22 Correct 94 ms 540 KB Output is correct
23 Correct 108 ms 584 KB Output is correct
24 Correct 102 ms 604 KB Output is correct
25 Correct 97 ms 572 KB Output is correct
26 Correct 71 ms 552 KB Output is correct
27 Correct 127 ms 736 KB Output is correct
28 Correct 107 ms 3060 KB Output is correct
29 Correct 115 ms 1460 KB Output is correct
30 Correct 60 ms 524 KB Output is correct
31 Correct 108 ms 3384 KB Output is correct
32 Correct 121 ms 1700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2075 ms 13628 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2088 ms 18344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 85 ms 544 KB Output is correct
3 Correct 28 ms 512 KB Output is correct
4 Correct 89 ms 708 KB Output is correct
5 Correct 90 ms 544 KB Output is correct
6 Correct 118 ms 716 KB Output is correct
7 Correct 125 ms 700 KB Output is correct
8 Correct 109 ms 524 KB Output is correct
9 Correct 97 ms 568 KB Output is correct
10 Correct 110 ms 676 KB Output is correct
11 Correct 96 ms 580 KB Output is correct
12 Correct 73 ms 660 KB Output is correct
13 Correct 118 ms 756 KB Output is correct
14 Correct 99 ms 1348 KB Output is correct
15 Correct 101 ms 1220 KB Output is correct
16 Correct 71 ms 520 KB Output is correct
17 Correct 106 ms 3320 KB Output is correct
18 Correct 103 ms 1632 KB Output is correct
19 Correct 97 ms 528 KB Output is correct
20 Correct 135 ms 764 KB Output is correct
21 Correct 117 ms 776 KB Output is correct
22 Correct 94 ms 540 KB Output is correct
23 Correct 108 ms 584 KB Output is correct
24 Correct 102 ms 604 KB Output is correct
25 Correct 97 ms 572 KB Output is correct
26 Correct 71 ms 552 KB Output is correct
27 Correct 127 ms 736 KB Output is correct
28 Correct 107 ms 3060 KB Output is correct
29 Correct 115 ms 1460 KB Output is correct
30 Correct 60 ms 524 KB Output is correct
31 Correct 108 ms 3384 KB Output is correct
32 Correct 121 ms 1700 KB Output is correct
33 Execution timed out 2075 ms 13628 KB Time limit exceeded
34 Halted 0 ms 0 KB -