Submission #1128706

#TimeUsernameProblemLanguageResultExecution timeMemory
1128706rayan_bdRegions (IOI09_regions)C++20
19 / 100
8074 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 } vector<int> adj[mxN]; vector<int> nodes; int col[mxN]; unordered_map<int,unordered_map<int,int>> answers; void dfs(int u){ nodes.pb(col[u]); int st=nodes.size(); for(auto it:adj[u]){ dfs(it); } for(int i=st;i<nodes.size();++i){ ++answers[col[u]][nodes[i]]; } } int main(){ //io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,r,q,u,man,reg;cin>>n>>r>>q; cin>>col[1]; for(int i=2;i<=n;++i){ cin>>u>>col[i]; adj[u].pb(i); } dfs(1); while(q--){ cin>>man>>reg; cout<<answers[man][reg]<<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:72:15: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   72 | void dfs(int u){
      |               ^
regions.cpp:72:15: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
regions.cpp:72:15: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
regions.cpp:72:15: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
regions.cpp:83:10: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   83 | int main(){
      |          ^
regions.cpp:83:10: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
regions.cpp:83:10: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
regions.cpp:83: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...