# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
248708 | 2020-07-13T08:20:37 Z | Lawliet | Synchronization (JOI13_synchronization) | C++17 | 117 ms | 16504 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; const int INF = 1000000010; int n, m, q; int mnTime[MAXN], mxTime[MAXN]; bool act[MAXN]; vector<int> adj[MAXN]; vector<int> indEdge[MAXN]; int DFS(int cur, int p, int t) { int ans = 1; for(int i = 0 ; i < (int)adj[cur].size() ; i++) { int viz = adj[cur][i]; int ind = indEdge[cur][i]; if( viz == p ) continue; if( t < mnTime[ind] ) continue; ans += DFS( viz , cur , min( t , mxTime[ind] ) ); } return ans; } int main() { scanf("%d %d %d",&n,&m,&q); for(int i = 1 ; i < n ; i++) { int U, V; scanf("%d %d",&U,&V); adj[U].push_back( V ); adj[V].push_back( U ); indEdge[U].push_back( i ); indEdge[V].push_back( i ); mnTime[i] = INF + 1; mxTime[i] = -INF - 1; } for(int i = 1 ; i <= m ; i++) { int ind; scanf("%d",&ind); if( !act[ind] ) mnTime[ind] = min( mnTime[ind] , i ); else mxTime[ind] = max( mxTime[ind] , i - 1 ); act[ind] = !act[ind]; } for(int i = 1 ; i < n ; i++) if( mnTime[i] != INF + 1 && mnTime[i] > mxTime[i] ) mxTime[i] = INF; for(int i = 1 ; i <= q ; i++) { int root; scanf("%d",&root); printf("%d\n",DFS( root , root , INF )); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 5 ms | 4992 KB | Output is correct |
3 | Incorrect | 3 ms | 4992 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 86 ms | 16504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 4992 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 117 ms | 12648 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Incorrect | 3 ms | 4992 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |