Submission #594234

# Submission time Handle Problem Language Result Execution time Memory
594234 2022-07-12T09:06:26 Z 장태환(#8433) Unique Cities (JOI19_ho_t5) C++17
4 / 100
2000 ms 11276 KB
#include <bits/stdc++.h>
using namespace std;
vector<int>link[200100];
int arr[201000];
int d[200100];
unordered_map<int, int>x,y;
void dfs(int n, int p = 0)
{
	int i;
	for (i = 0; i < link[n].size(); i++)
	{
		if (link[n][i] == p)
			continue;
		d[link[n][i]] = d[n] + 1;
		dfs(link[n][i], n);
		
	}
}
signed main()
{
	int N, M;
	cin >> N >> M;
	int i;
	for (i = 1; i < N; i++)
	{
		int a, b;
		cin >> a >> b;
		link[a].push_back(b);
		link[b].push_back(a);
	}
	for(i=1;i<=N;i++)
		cin >> arr[i];
	for (i = 1; i <= N; i++)
	{
		dfs(i);
		int j;
		x.clear();
		y.clear();
		for (j = 1; j <= N; j++)
		{
			if (i == j)
				continue;
			x[d[j]]++;
		}
		for (j = 1; j <= N; j++)
		{
			if (i == j)
				continue;
			if (x[d[j]] == 1)
				y[arr[j]]++;
		}
		cout << y.size() << '\n';

	}
}

Compilation message

joi2019_ho_t5.cpp: In function 'void dfs(int, int)':
joi2019_ho_t5.cpp:10:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for (i = 0; i < link[n].size(); i++)
      |              ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 123 ms 5076 KB Output is correct
3 Correct 74 ms 5152 KB Output is correct
4 Correct 173 ms 5176 KB Output is correct
5 Correct 157 ms 5076 KB Output is correct
6 Correct 291 ms 5312 KB Output is correct
7 Correct 230 ms 5192 KB Output is correct
8 Correct 133 ms 5096 KB Output is correct
9 Correct 154 ms 5076 KB Output is correct
10 Correct 159 ms 5076 KB Output is correct
11 Correct 158 ms 5104 KB Output is correct
12 Correct 115 ms 5096 KB Output is correct
13 Correct 296 ms 5284 KB Output is correct
14 Correct 196 ms 5172 KB Output is correct
15 Correct 182 ms 5180 KB Output is correct
16 Correct 107 ms 5196 KB Output is correct
17 Correct 225 ms 5240 KB Output is correct
18 Correct 207 ms 5204 KB Output is correct
19 Correct 145 ms 5096 KB Output is correct
20 Correct 341 ms 5360 KB Output is correct
21 Correct 207 ms 5220 KB Output is correct
22 Correct 133 ms 5096 KB Output is correct
23 Correct 149 ms 5128 KB Output is correct
24 Correct 147 ms 5132 KB Output is correct
25 Correct 147 ms 5112 KB Output is correct
26 Correct 108 ms 5076 KB Output is correct
27 Correct 288 ms 5296 KB Output is correct
28 Correct 240 ms 5268 KB Output is correct
29 Correct 188 ms 5192 KB Output is correct
30 Correct 103 ms 5104 KB Output is correct
31 Correct 233 ms 5212 KB Output is correct
32 Correct 200 ms 5216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2074 ms 9688 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2083 ms 11276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 123 ms 5076 KB Output is correct
3 Correct 74 ms 5152 KB Output is correct
4 Correct 173 ms 5176 KB Output is correct
5 Correct 157 ms 5076 KB Output is correct
6 Correct 291 ms 5312 KB Output is correct
7 Correct 230 ms 5192 KB Output is correct
8 Correct 133 ms 5096 KB Output is correct
9 Correct 154 ms 5076 KB Output is correct
10 Correct 159 ms 5076 KB Output is correct
11 Correct 158 ms 5104 KB Output is correct
12 Correct 115 ms 5096 KB Output is correct
13 Correct 296 ms 5284 KB Output is correct
14 Correct 196 ms 5172 KB Output is correct
15 Correct 182 ms 5180 KB Output is correct
16 Correct 107 ms 5196 KB Output is correct
17 Correct 225 ms 5240 KB Output is correct
18 Correct 207 ms 5204 KB Output is correct
19 Correct 145 ms 5096 KB Output is correct
20 Correct 341 ms 5360 KB Output is correct
21 Correct 207 ms 5220 KB Output is correct
22 Correct 133 ms 5096 KB Output is correct
23 Correct 149 ms 5128 KB Output is correct
24 Correct 147 ms 5132 KB Output is correct
25 Correct 147 ms 5112 KB Output is correct
26 Correct 108 ms 5076 KB Output is correct
27 Correct 288 ms 5296 KB Output is correct
28 Correct 240 ms 5268 KB Output is correct
29 Correct 188 ms 5192 KB Output is correct
30 Correct 103 ms 5104 KB Output is correct
31 Correct 233 ms 5212 KB Output is correct
32 Correct 200 ms 5216 KB Output is correct
33 Execution timed out 2074 ms 9688 KB Time limit exceeded
34 Halted 0 ms 0 KB -