# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1083271 | 2024-09-02T20:05:38 Z | rayan_bd | Regions (IOI09_regions) | C++17 | 246 ms | 131072 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long const int mxN = 2e5 + 5000; ll color[mxN][505]; vector<ll> adj[mxN]; ll hd[mxN],out[mxN]; unordered_map<ll,vector<ll>> mp; void solve(ll tc) { ll n,r,q,r1,r2,super;cin>>n>>r>>q; cin>>hd[1]; mp[hd[1]].pb(1); color[1][hd[1]]=1; for(ll i=2;i<=n;++i){ cin>>super>>hd[i]; adj[i].pb(super); mp[hd[i]].pb(i); color[i][hd[i]]=1; ++out[super]; } set<ll> st; for(ll i=1;i<=n;++i){ if(out[i]==0){ st.insert(i); } } while(st.size()){ ll u=*st.begin(); st.erase(u); for(auto it:adj[u]){ for(ll i=1;i<505;++i){ color[it][i]+=color[u][i]; } if(--out[it]==0) st.insert(it); } } while(q--){ cin>>r1>>r2; ll ans=0; for(auto it:mp[hd[r1]]){ ans+=color[it][r2]; } cout.flush()<<ans<<'\n'; cout.flush(); } } void testing(){ #ifndef ONLINE_JUDGE freopen("input.in","r",stdin); freopen("output.out","w",stdout); #endif } int main() { //testing(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(0); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 5208 KB | Output isn't correct |
2 | Incorrect | 2 ms | 5208 KB | Output isn't correct |
3 | Incorrect | 3 ms | 5464 KB | Output isn't correct |
4 | Incorrect | 4 ms | 5720 KB | Output isn't correct |
5 | Incorrect | 7 ms | 7256 KB | Output isn't correct |
6 | Incorrect | 11 ms | 8280 KB | Output isn't correct |
7 | Incorrect | 16 ms | 11096 KB | Output isn't correct |
8 | Incorrect | 19 ms | 13144 KB | Output isn't correct |
9 | Incorrect | 37 ms | 25176 KB | Output isn't correct |
10 | Incorrect | 59 ms | 45144 KB | Output isn't correct |
11 | Incorrect | 106 ms | 65360 KB | Output isn't correct |
12 | Incorrect | 134 ms | 85328 KB | Output isn't correct |
13 | Incorrect | 157 ms | 98784 KB | Output isn't correct |
14 | Incorrect | 195 ms | 125504 KB | Output isn't correct |
15 | Runtime error | 51 ms | 131072 KB | Execution killed with signal 9 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 64 ms | 131072 KB | Execution killed with signal 9 |
2 | Runtime error | 52 ms | 131072 KB | Execution killed with signal 9 |
3 | Runtime error | 53 ms | 131072 KB | Execution killed with signal 9 |
4 | Incorrect | 246 ms | 122784 KB | Output isn't correct |
5 | Runtime error | 65 ms | 131072 KB | Execution killed with signal 9 |
6 | Runtime error | 57 ms | 131072 KB | Execution killed with signal 9 |
7 | Runtime error | 57 ms | 131072 KB | Execution killed with signal 9 |
8 | Runtime error | 58 ms | 131072 KB | Execution killed with signal 9 |
9 | Runtime error | 53 ms | 131072 KB | Execution killed with signal 9 |
10 | Runtime error | 61 ms | 131072 KB | Execution killed with signal 9 |
11 | Runtime error | 60 ms | 131072 KB | Execution killed with signal 9 |
12 | Runtime error | 53 ms | 131072 KB | Execution killed with signal 9 |
13 | Runtime error | 57 ms | 131072 KB | Execution killed with signal 9 |
14 | Runtime error | 60 ms | 131072 KB | Execution killed with signal 9 |
15 | Runtime error | 59 ms | 131072 KB | Execution killed with signal 9 |
16 | Runtime error | 60 ms | 131072 KB | Execution killed with signal 9 |
17 | Runtime error | 58 ms | 131072 KB | Execution killed with signal 9 |