# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68216 | 2018-08-16T08:43:23 Z | top34051 | Synchronization (JOI13_synchronization) | C++17 | 8000 ms | 37848 KB |
//subtask 1 #include<bits/stdc++.h> using namespace std; #define pii pair<int,int> #define X first #define Y second const int maxn = 2e5 + 5; int n,m,q; vector<int> way[maxn]; pii e[maxn]; int open[maxn]; vector<pii> pos[maxn]; vector<pii> add[maxn]; int ask[maxn]; int res[maxn]; void solve(int u, int last) { add[u].clear(); for(auto v : way[u]) { if(v==last) continue; solve(v,u); } sort(add[u].begin(),add[u].end()); int i = 0, sum = 1, prev = 0; for(auto t : pos[u]) { int x = t.X, up = t.Y; while(i<add[u].size() && add[u][i].X <= x) sum += add[u][i++].Y; // printf("%d : pos = %d : sum = %d\n",u,x,sum); if(up==last) { //// printf("\tupdate %d : %d %d\n",up,x,sum-prev); add[up].push_back({x,sum-prev}); prev = sum; } } res[u] = sum; } int main() { scanf("%d%d%d",&n,&m,&q); for(int i=1;i<n;i++) { int u,v; scanf("%d%d",&u,&v); way[u].push_back(v); way[v].push_back(u); e[i] = {u,v}; } for(int i=1;i<=m;i++) { int x; scanf("%d",&x); if(!open[x]) { pos[e[x].X].push_back({i,e[x].Y}); pos[e[x].Y].push_back({i,e[x].X}); open[x] = 1; } else { pos[e[x].X].push_back({i-1,e[x].Y}); pos[e[x].Y].push_back({i-1,e[x].X}); open[x] = 0; } } for(int i=1;i<=q;i++) { int x; scanf("%d",&x); solve(x,0); printf("%d\n",res[x]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 14456 KB | Output is correct |
2 | Correct | 17 ms | 14564 KB | Output is correct |
3 | Incorrect | 17 ms | 14624 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 128 ms | 32948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 17 ms | 32948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 8041 ms | 37848 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 37848 KB | Output is correct |
2 | Correct | 16 ms | 37848 KB | Output is correct |
3 | Incorrect | 16 ms | 37848 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |