Submission #1128694

#TimeUsernameProblemLanguageResultExecution timeMemory
1128694rayan_bdRegions (IOI09_regions)C++20
0 / 100
138 ms196608 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-fwhole-program") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-fstrict-overflow") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-skip-blocks") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("inline-small-functions") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fexpensive-optimizations") #pragma GCC optimize("-funsafe-loop-optimizations") #pragma GCC optimize("inline-functions-called-once") #pragma GCC optimize("-fdelete-null-pointer-checks") #define pb push_back #define fi first #define se second #define all(x) x.begin(),x.end() const int mxN = 2e5+1; void io(){ #ifndef ONLINE_JUDGE freopen("input.in","r",stdin); freopen("output.out","w",stdout); #endif } set<int> adj[mxN]; int dp[mxN][501]; 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].insert(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:25:39: warning: bad option '-fwhole-program' to pragma 'optimize' [-Wpragmas]
   25 | #pragma GCC optimize("-fwhole-program")
      |                                       ^
regions.cpp:32:41: warning: bad option '-fstrict-overflow' to pragma 'optimize' [-Wpragmas]
   32 | #pragma GCC optimize("-fstrict-overflow")
      |                                         ^
regions.cpp:34:41: warning: bad option '-fcse-skip-blocks' to pragma 'optimize' [-Wpragmas]
   34 | #pragma GCC optimize("-fcse-skip-blocks")
      |                                         ^
regions.cpp:48:51: warning: bad option '-funsafe-loop-optimizations' to pragma 'optimize' [-Wpragmas]
   48 | #pragma GCC optimize("-funsafe-loop-optimizations")
      |                                                   ^
regions.cpp:59:9: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   59 | void io(){
      |         ^
regions.cpp:59:9: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
regions.cpp:59:9: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
regions.cpp:59:9: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
regions.cpp:70:15: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   70 | void dfs(int u){
      |               ^
regions.cpp:70:15: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
regions.cpp:70:15: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
regions.cpp:70:15: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
regions.cpp:80:10: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   80 | int main(){
      |          ^
regions.cpp:80:10: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
regions.cpp:80:10: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
regions.cpp:80:10: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
regions.cpp: In function 'void io()':
regions.cpp:61:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |     freopen("input.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
regions.cpp:62:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |     freopen("output.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...