답안 #1013399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013399 2024-07-03T13:55:34 Z vjudge1 Regions (IOI09_regions) C++17
30 / 100
5578 ms 131076 KB
#include<bits/stdc++.h>
using namespace std;
#ifdef ONPC
#include"debug.h"
#else
#define debug(...) 42
#endif
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
const int mod = 1e9 + 7;
const int MAXN = 1e6 + 15;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int C = 500;
int frq[MAXN], col[MAXN];
int n, r, q;
vector<int> deco;
int ans[503][25001];
pii upper;
vector<int> adj[MAXN];
void dfs(int node, int cnt){
	ans[upper.S][col[node]] += cnt;
	if (col[node] == upper.F) cnt++;
	for (auto to : adj[node]){
		dfs(to, cnt);
	}
}

int main(){
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
	cin >> n >> r >> q >> col[1];
	for (int i = 2; i <= n; i++){
		int p, c;
		cin >> p >> c;
		adj[p].pb(i);
		col[i] = c;
		frq[c]++;
	}
	for (int i = 0; i <= 25000; i++){
		if (frq[i] >= C){
			deco.pb(i);
		}
	}
	for (int i = 1; i <= r; i++){
		upper = {i, i};
		dfs(1, 0);
	}
	//for (int i = 0; i < sz(deco); i++){
		//upper = {deco[i], i};
		//dfs(1, 0);
	//}
	while (q--){
		int e1, e2;
		cin >> e1 >> e2;
		cout << ans[e1][e2] << endl;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 29272 KB Output is correct
2 Correct 4 ms 29272 KB Output is correct
3 Correct 7 ms 31320 KB Output is correct
4 Correct 8 ms 33368 KB Output is correct
5 Correct 9 ms 33620 KB Output is correct
6 Correct 14 ms 46168 KB Output is correct
7 Correct 19 ms 43740 KB Output is correct
8 Correct 20 ms 47704 KB Output is correct
9 Correct 40 ms 50520 KB Output is correct
10 Correct 89 ms 49232 KB Output is correct
11 Correct 132 ms 48464 KB Output is correct
12 Correct 169 ms 46160 KB Output is correct
13 Correct 205 ms 52816 KB Output is correct
14 Correct 189 ms 44476 KB Output is correct
15 Correct 159 ms 46416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 728 ms 50452 KB Output is correct
2 Correct 893 ms 51424 KB Output is correct
3 Correct 994 ms 53824 KB Output is correct
4 Runtime error 328 ms 115024 KB Execution killed with signal 11
5 Runtime error 167 ms 122964 KB Execution killed with signal 11
6 Runtime error 556 ms 123988 KB Execution killed with signal 11
7 Runtime error 2986 ms 131076 KB Execution killed with signal 9
8 Runtime error 2632 ms 131072 KB Execution killed with signal 9
9 Runtime error 4097 ms 131072 KB Execution killed with signal 9
10 Runtime error 2821 ms 131072 KB Execution killed with signal 9
11 Runtime error 4307 ms 131072 KB Execution killed with signal 9
12 Runtime error 5578 ms 131072 KB Execution killed with signal 9
13 Runtime error 4281 ms 131072 KB Execution killed with signal 9
14 Runtime error 5428 ms 131072 KB Execution killed with signal 9
15 Runtime error 3265 ms 131076 KB Execution killed with signal 9
16 Runtime error 3019 ms 131072 KB Execution killed with signal 9
17 Runtime error 2805 ms 131072 KB Execution killed with signal 9