# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1083267 | 2024-09-02T19:56:37 Z | rayan_bd | Regions (IOI09_regions) | C++17 | 281 ms | 131072 KB |
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; #define getar(ar,n) for(ll i=0;i<n;++i) cin>>ar[i] #define show(n) cout<<n<<'\n' #define all(v) v.begin(), v.end() #define br cout<<"\n" #define pb push_back #define nl '\n' #define yes cout<<"YES\n" #define no cout<<"NO\n" #define ret return #define ll long long #define ld long double #define sza(x) ((int)x.size()) const int mxN = 2e5 + 5000; const ll MOD = 1e9 + 7; const ll INF = 1e9; const ld EPS = 1e-9; 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<<ans<<endl; } } 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 6232 KB | Output isn't correct |
2 | Incorrect | 2 ms | 6232 KB | Output isn't correct |
3 | Incorrect | 3 ms | 6232 KB | Output isn't correct |
4 | Incorrect | 4 ms | 6744 KB | Output isn't correct |
5 | Incorrect | 6 ms | 8280 KB | Output isn't correct |
6 | Incorrect | 12 ms | 9304 KB | Output isn't correct |
7 | Incorrect | 23 ms | 12120 KB | Output isn't correct |
8 | Incorrect | 20 ms | 14168 KB | Output isn't correct |
9 | Incorrect | 27 ms | 26200 KB | Output isn't correct |
10 | Incorrect | 68 ms | 46164 KB | Output isn't correct |
11 | Incorrect | 103 ms | 66384 KB | Output isn't correct |
12 | Incorrect | 142 ms | 86352 KB | Output isn't correct |
13 | Incorrect | 163 ms | 99920 KB | Output isn't correct |
14 | Incorrect | 197 ms | 126668 KB | Output isn't correct |
15 | Runtime error | 46 ms | 131072 KB | Execution killed with signal 9 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 53 ms | 131072 KB | Execution killed with signal 9 |
2 | Runtime error | 57 ms | 131072 KB | Execution killed with signal 9 |
3 | Runtime error | 54 ms | 131072 KB | Execution killed with signal 9 |
4 | Incorrect | 281 ms | 123728 KB | Output isn't correct |
5 | Runtime error | 67 ms | 131072 KB | Execution killed with signal 9 |
6 | Runtime error | 59 ms | 131072 KB | Execution killed with signal 9 |
7 | Runtime error | 56 ms | 131072 KB | Execution killed with signal 9 |
8 | Runtime error | 61 ms | 131072 KB | Execution killed with signal 9 |
9 | Runtime error | 56 ms | 131072 KB | Execution killed with signal 9 |
10 | Runtime error | 57 ms | 131072 KB | Execution killed with signal 9 |
11 | Runtime error | 56 ms | 131072 KB | Execution killed with signal 9 |
12 | Runtime error | 56 ms | 131072 KB | Execution killed with signal 9 |
13 | Runtime error | 58 ms | 131072 KB | Execution killed with signal 9 |
14 | Runtime error | 56 ms | 131072 KB | Execution killed with signal 9 |
15 | Runtime error | 60 ms | 131072 KB | Execution killed with signal 9 |
16 | Runtime error | 67 ms | 131072 KB | Execution killed with signal 9 |
17 | Runtime error | 61 ms | 131072 KB | Execution killed with signal 9 |