Submission #202613

# Submission time Handle Problem Language Result Execution time Memory
202613 2020-02-17T09:32:08 Z dndhk Unique Cities (JOI19_ho_t5) C++14
4 / 100
2000 ms 16120 KB
#include <bits/stdc++.h>

#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX_N = 200000;

int N, M;
int c[MAX_N+1];
vector<int> gp[MAX_N+1];
int vst[MAX_N+1];
int lv[MAX_N+1], p[MAX_N+1];

int cnt[MAX_N+1];
set<int> st;

void dfs(int x){
	cnt[lv[x]]++;
	for(int i : gp[x]){
		if(i==p[x])	continue;
		p[i] = x;
		lv[i] = lv[x]+1;
		dfs(i);
	}
}


int main(){
	scanf("%d%d", &N, &M);
	for(int i=1; i<N; i++){
		int a, b; scanf("%d%d", &a, &b);
		gp[a].pb(b); gp[b].pb(a);
	}
	for(int i=1; i<=N; i++){
		scanf("%d", &c[i]);
	}
	for(int i=1; i<=N; i++){
		for(int j=1; j<=N; j++)	cnt[j] = vst[j] = lv[j] = p[j] = 0;
		lv[i] = 1;	dfs(i);
		st.clear();
		for(int j=1; j<=N; j++){
			if(i==j)	continue;
			if(cnt[lv[j]]==1){
				st.insert(c[j]);
			}
		}
		printf("%d\n", (int)st.size());
	}

	return 0;
}

Compilation message

joi2019_ho_t5.cpp: In function 'int main()':
joi2019_ho_t5.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
joi2019_ho_t5.cpp:36:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a, b; scanf("%d%d", &a, &b);
             ~~~~~^~~~~~~~~~~~~~~~
joi2019_ho_t5.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &c[i]);
   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 5112 KB Output is correct
2 Correct 81 ms 5112 KB Output is correct
3 Correct 82 ms 5240 KB Output is correct
4 Correct 103 ms 5240 KB Output is correct
5 Correct 96 ms 5112 KB Output is correct
6 Correct 158 ms 5296 KB Output is correct
7 Correct 107 ms 5368 KB Output is correct
8 Correct 93 ms 5112 KB Output is correct
9 Correct 98 ms 5112 KB Output is correct
10 Correct 99 ms 5240 KB Output is correct
11 Correct 94 ms 5112 KB Output is correct
12 Correct 76 ms 5112 KB Output is correct
13 Correct 152 ms 5368 KB Output is correct
14 Correct 101 ms 5368 KB Output is correct
15 Correct 104 ms 5240 KB Output is correct
16 Correct 67 ms 5112 KB Output is correct
17 Correct 115 ms 5276 KB Output is correct
18 Correct 99 ms 5240 KB Output is correct
19 Correct 94 ms 5112 KB Output is correct
20 Correct 368 ms 5368 KB Output is correct
21 Correct 127 ms 5240 KB Output is correct
22 Correct 94 ms 5240 KB Output is correct
23 Correct 104 ms 5224 KB Output is correct
24 Correct 95 ms 5112 KB Output is correct
25 Correct 95 ms 5112 KB Output is correct
26 Correct 74 ms 5112 KB Output is correct
27 Correct 249 ms 5240 KB Output is correct
28 Correct 190 ms 5240 KB Output is correct
29 Correct 112 ms 5368 KB Output is correct
30 Correct 67 ms 5112 KB Output is correct
31 Correct 180 ms 5240 KB Output is correct
32 Correct 120 ms 5240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 34 ms 7664 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2037 ms 16120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 5112 KB Output is correct
2 Correct 81 ms 5112 KB Output is correct
3 Correct 82 ms 5240 KB Output is correct
4 Correct 103 ms 5240 KB Output is correct
5 Correct 96 ms 5112 KB Output is correct
6 Correct 158 ms 5296 KB Output is correct
7 Correct 107 ms 5368 KB Output is correct
8 Correct 93 ms 5112 KB Output is correct
9 Correct 98 ms 5112 KB Output is correct
10 Correct 99 ms 5240 KB Output is correct
11 Correct 94 ms 5112 KB Output is correct
12 Correct 76 ms 5112 KB Output is correct
13 Correct 152 ms 5368 KB Output is correct
14 Correct 101 ms 5368 KB Output is correct
15 Correct 104 ms 5240 KB Output is correct
16 Correct 67 ms 5112 KB Output is correct
17 Correct 115 ms 5276 KB Output is correct
18 Correct 99 ms 5240 KB Output is correct
19 Correct 94 ms 5112 KB Output is correct
20 Correct 368 ms 5368 KB Output is correct
21 Correct 127 ms 5240 KB Output is correct
22 Correct 94 ms 5240 KB Output is correct
23 Correct 104 ms 5224 KB Output is correct
24 Correct 95 ms 5112 KB Output is correct
25 Correct 95 ms 5112 KB Output is correct
26 Correct 74 ms 5112 KB Output is correct
27 Correct 249 ms 5240 KB Output is correct
28 Correct 190 ms 5240 KB Output is correct
29 Correct 112 ms 5368 KB Output is correct
30 Correct 67 ms 5112 KB Output is correct
31 Correct 180 ms 5240 KB Output is correct
32 Correct 120 ms 5240 KB Output is correct
33 Execution timed out 34 ms 7664 KB Time limit exceeded (wall clock)
34 Halted 0 ms 0 KB -