제출 #649619

#제출 시각아이디문제언어결과실행 시간메모리
649619mychecksedadRegions (IOI09_regions)C++17
25 / 100
1002 ms131072 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long int ll; typedef long double ld; #define MOD (1000000000+7) #define MOD1 (998244353) #define PI 3.1415926535 #define pb push_back #define setp() cout << setprecision(15) #define all(x) x.begin(), x.end() #define debug(x) cerr << #x << " is " << x << '\n'; const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20; int n, q, r, a[N], ans[1000][1000]; vector<int> g[N], R[N]; void dfs(int v, int p){ R[v].resize(r + 5); for(int u: g[v]){ if(u == p) continue; dfs(u, v); for(int j = 1; j <= r; ++j) R[v][j] += R[u][j]; } for(int j = 1; j <= r; ++j) ans[a[v]][j] += R[v][j]; R[v][a[v]]++; } void solve(){ cin >> n >> r >> q; cin >> a[1]; for(int i = 2; i <= n; ++i){ int x; cin >> x >> a[i]; g[x].pb(i); g[i].pb(x); } for(int i = 0; i <= r; ++i) for(int j = 0; j <= r; ++j) ans[i][j] = 0; dfs(1, 1); for(;q--;){ int a, b; cin >> a >> b; cout << ans[a][b] << endl; } } int main(){ cin.tie(0); ios::sync_with_stdio(0); int T = 1, aa; // cin >> T;aa=T; while(T--){ // cout << "Case #" << aa-T << ": "; solve(); // cout << '\n'; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

regions.cpp: In function 'int main()':
regions.cpp:54:16: warning: unused variable 'aa' [-Wunused-variable]
   54 |     int T = 1, aa;
      |                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...