Submission #1117578

# Submission time Handle Problem Language Result Execution time Memory
1117578 2024-11-24T06:18:02 Z vjudge1 Unique Cities (JOI19_ho_t5) C++17
4 / 100
2000 ms 21320 KB
//UNSTOPPABLE
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define pii pair<int,int>
#define tpii pair <pair <int,int> , int>
#define bruh cout << "NO\n"
using namespace std;
using namespace __gnu_pbds;
const int N = 3e5 + 5;
int mod = 1e9 + 7;
const int INF = 1e18;
int n,m,d[N],ban[N],val[N],a[N];
vector <int> g[N];
set <int> ans,st;
void dfs(int v , int p = 0){
	for(auto to : g[v]){
		if(to == p) continue;
		d[to] = d[v] + 1;
		dfs(to , v);
	}
	if(p && !ban[d[v]]){
		if(st.find(d[v]) != st.end()){
			ban[d[v]] = 1;
		}
		else{
			st.insert(d[v]);
			val[d[v]] = a[v];
		}
	}
}
void Gold(){
	cin >> n >> m;
	for(int i = 1 ; i < n ; i++){
		int u,v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	for(int i = 1 ; i <= n ; i++) cin >> a[i];
	for(int i = 1 ; i <= n ; i++){
		st.clear();
		ans.clear();
		for(int j = 1 ; j <= n ; j++){
			d[j] = 0;
			ban[j] = 0;
			val[j] = 0;
		}
		dfs(i);
		int res = 0;
		for(auto it : st){
			if(!ban[it]){
				ans.insert(val[it]);
			}
		}
		cout << ans.size() << '\n';
	}
}
signed main(/*Zhunussov Temirlan*/){
	//freopen("txt.in","r",stdin);
	//freopen("txt.out","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	srand(time(0));
	int TT = 1;
	// cin >> TT;
	for(int i = 1 ; i <= TT ; i++){
		//cout << "Case " << i << ": ";
		Gold();
	}
}

Compilation message

joi2019_ho_t5.cpp: In function 'void Gold()':
joi2019_ho_t5.cpp:58:7: warning: unused variable 'res' [-Wunused-variable]
   58 |   int res = 0;
      |       ^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 14928 KB Output is correct
2 Correct 45 ms 15076 KB Output is correct
3 Correct 121 ms 15132 KB Output is correct
4 Correct 191 ms 14928 KB Output is correct
5 Correct 48 ms 15080 KB Output is correct
6 Correct 429 ms 15184 KB Output is correct
7 Correct 218 ms 14928 KB Output is correct
8 Correct 30 ms 14928 KB Output is correct
9 Correct 94 ms 14928 KB Output is correct
10 Correct 87 ms 14928 KB Output is correct
11 Correct 64 ms 14928 KB Output is correct
12 Correct 21 ms 14928 KB Output is correct
13 Correct 466 ms 15440 KB Output is correct
14 Correct 207 ms 14928 KB Output is correct
15 Correct 204 ms 15120 KB Output is correct
16 Correct 18 ms 14928 KB Output is correct
17 Correct 241 ms 15188 KB Output is correct
18 Correct 209 ms 14928 KB Output is correct
19 Correct 46 ms 14928 KB Output is correct
20 Correct 570 ms 15352 KB Output is correct
21 Correct 231 ms 15160 KB Output is correct
22 Correct 31 ms 14928 KB Output is correct
23 Correct 106 ms 15096 KB Output is correct
24 Correct 65 ms 14928 KB Output is correct
25 Correct 66 ms 14928 KB Output is correct
26 Correct 20 ms 14928 KB Output is correct
27 Correct 500 ms 15232 KB Output is correct
28 Correct 337 ms 15432 KB Output is correct
29 Correct 240 ms 15148 KB Output is correct
30 Correct 17 ms 15088 KB Output is correct
31 Correct 279 ms 15196 KB Output is correct
32 Correct 238 ms 15176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2061 ms 19448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2032 ms 21320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 14928 KB Output is correct
2 Correct 45 ms 15076 KB Output is correct
3 Correct 121 ms 15132 KB Output is correct
4 Correct 191 ms 14928 KB Output is correct
5 Correct 48 ms 15080 KB Output is correct
6 Correct 429 ms 15184 KB Output is correct
7 Correct 218 ms 14928 KB Output is correct
8 Correct 30 ms 14928 KB Output is correct
9 Correct 94 ms 14928 KB Output is correct
10 Correct 87 ms 14928 KB Output is correct
11 Correct 64 ms 14928 KB Output is correct
12 Correct 21 ms 14928 KB Output is correct
13 Correct 466 ms 15440 KB Output is correct
14 Correct 207 ms 14928 KB Output is correct
15 Correct 204 ms 15120 KB Output is correct
16 Correct 18 ms 14928 KB Output is correct
17 Correct 241 ms 15188 KB Output is correct
18 Correct 209 ms 14928 KB Output is correct
19 Correct 46 ms 14928 KB Output is correct
20 Correct 570 ms 15352 KB Output is correct
21 Correct 231 ms 15160 KB Output is correct
22 Correct 31 ms 14928 KB Output is correct
23 Correct 106 ms 15096 KB Output is correct
24 Correct 65 ms 14928 KB Output is correct
25 Correct 66 ms 14928 KB Output is correct
26 Correct 20 ms 14928 KB Output is correct
27 Correct 500 ms 15232 KB Output is correct
28 Correct 337 ms 15432 KB Output is correct
29 Correct 240 ms 15148 KB Output is correct
30 Correct 17 ms 15088 KB Output is correct
31 Correct 279 ms 15196 KB Output is correct
32 Correct 238 ms 15176 KB Output is correct
33 Execution timed out 2061 ms 19448 KB Time limit exceeded
34 Halted 0 ms 0 KB -