Submission #1128692

#TimeUsernameProblemLanguageResultExecution timeMemory
1128692rayan_bdRegions (IOI09_regions)C++20
0 / 100
159 ms196608 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define all(x) x.begin(),x.end() const int mxN = 2e5+5000; void io(){ #ifndef ONLINE_JUDGE freopen("input.in","r",stdin); freopen("output.out","w",stdout); #endif } vector<int> adj[mxN]; int dp[mxN][505]; void dfs(int u){ for(auto it:adj[u]){ dfs(it); for(int i=1;i<=500;++i){ dp[u][i]+=dp[it][i]; } } } int main(){ // io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); memset(dp,0,sizeof(dp)); int n,r,q,u,man,reg;cin>>n>>r>>q; cin>>u; ++dp[1][u]; dp[1][0]=u; for(int i=2;i<=n;++i){ cin>>u>>man; adj[u].pb(i); ++dp[i][man]; dp[i][0]=man; } dfs(1); while(q--){ cin>>man>>reg; int ans=0; for(int i=1;i<=n;++i){ if(dp[i][0]!=man) continue; ans+=dp[i][reg]; } cout<<ans<<endl; } return 0; }

Compilation message (stderr)

regions.cpp: In function 'void io()':
regions.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen("input.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
regions.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen("output.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...