Submission #670380

# Submission time Handle Problem Language Result Execution time Memory
670380 2022-12-08T19:56:33 Z dozer Unique Cities (JOI19_ho_t5) C++14
4 / 100
238 ms 3272 KB
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define endl "\n"
#define sp " "
#define N 2005

vector<int> dist[N];
int arr[N];
vector<int> adj[N];

void dfs(int node, int root, int d)
{
	dist[d].pb(arr[node]);
	for (auto i : adj[node])
		if (i != root) dfs(i, node, d + 1);
}

int32_t main()
{
	fastio();

	int n, m;
	cin>>n>>m;
	for (int i = 1; i < n; i++)
	{
		int u, v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	for (int i = 1; i <= n; i++)
		cin>>arr[i];

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++) dist[j].clear();
		dfs(i, 0, 1);
		set<int> s;
		for (int j = 2; j <= n; j++)
		{
			if (dist[j].size() == 1) s.insert(dist[j].front());
		}
		cout<<s.size()<<endl;
	}

	cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 47 ms 468 KB Output is correct
3 Correct 52 ms 544 KB Output is correct
4 Correct 67 ms 700 KB Output is correct
5 Correct 57 ms 560 KB Output is correct
6 Correct 102 ms 596 KB Output is correct
7 Correct 68 ms 596 KB Output is correct
8 Correct 53 ms 584 KB Output is correct
9 Correct 59 ms 468 KB Output is correct
10 Correct 59 ms 676 KB Output is correct
11 Correct 60 ms 468 KB Output is correct
12 Correct 37 ms 560 KB Output is correct
13 Correct 98 ms 660 KB Output is correct
14 Correct 64 ms 1492 KB Output is correct
15 Correct 66 ms 1392 KB Output is correct
16 Correct 30 ms 468 KB Output is correct
17 Correct 71 ms 3272 KB Output is correct
18 Correct 69 ms 1552 KB Output is correct
19 Correct 58 ms 468 KB Output is correct
20 Correct 238 ms 712 KB Output is correct
21 Correct 85 ms 688 KB Output is correct
22 Correct 53 ms 468 KB Output is correct
23 Correct 60 ms 576 KB Output is correct
24 Correct 58 ms 596 KB Output is correct
25 Correct 57 ms 468 KB Output is correct
26 Correct 38 ms 468 KB Output is correct
27 Correct 175 ms 596 KB Output is correct
28 Correct 141 ms 3220 KB Output is correct
29 Correct 83 ms 1400 KB Output is correct
30 Correct 31 ms 532 KB Output is correct
31 Correct 114 ms 3252 KB Output is correct
32 Correct 82 ms 1592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 688 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 47 ms 468 KB Output is correct
3 Correct 52 ms 544 KB Output is correct
4 Correct 67 ms 700 KB Output is correct
5 Correct 57 ms 560 KB Output is correct
6 Correct 102 ms 596 KB Output is correct
7 Correct 68 ms 596 KB Output is correct
8 Correct 53 ms 584 KB Output is correct
9 Correct 59 ms 468 KB Output is correct
10 Correct 59 ms 676 KB Output is correct
11 Correct 60 ms 468 KB Output is correct
12 Correct 37 ms 560 KB Output is correct
13 Correct 98 ms 660 KB Output is correct
14 Correct 64 ms 1492 KB Output is correct
15 Correct 66 ms 1392 KB Output is correct
16 Correct 30 ms 468 KB Output is correct
17 Correct 71 ms 3272 KB Output is correct
18 Correct 69 ms 1552 KB Output is correct
19 Correct 58 ms 468 KB Output is correct
20 Correct 238 ms 712 KB Output is correct
21 Correct 85 ms 688 KB Output is correct
22 Correct 53 ms 468 KB Output is correct
23 Correct 60 ms 576 KB Output is correct
24 Correct 58 ms 596 KB Output is correct
25 Correct 57 ms 468 KB Output is correct
26 Correct 38 ms 468 KB Output is correct
27 Correct 175 ms 596 KB Output is correct
28 Correct 141 ms 3220 KB Output is correct
29 Correct 83 ms 1400 KB Output is correct
30 Correct 31 ms 532 KB Output is correct
31 Correct 114 ms 3252 KB Output is correct
32 Correct 82 ms 1592 KB Output is correct
33 Runtime error 1 ms 688 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -