# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
603488 | 2022-07-24T07:35:17 Z | 조영욱(#8429) | Synchronization (JOI13_synchronization) | C++17 | 118 ms | 25608 KB |
#include <bits/stdc++.h> using namespace std; int n,m,q; typedef pair<int,int> P; P edge[100000]; int ont[100000]; typedef pair<int,int> P; vector<P> adj[100001]; set<P> s[100000]; int dp[100000]; void dfs(int v,int pr) { for(int i=0;i<adj[v].size();i++) { int nt=adj[v][i].first; int ind=adj[v][i].second; if (nt==pr) { continue; } if (dp[v]!=-1) { auto iter=s[ind].lower_bound(P(dp[v]+1,-1)); if (iter!=s[ind].begin()) { iter--; if ((*iter).second>=dp[v]) { dp[nt]=dp[v]; } else { dp[nt]=(*iter).second; } } } dfs(nt,v); } } int main(void) { scanf("%d %d %d",&n,&m,&q); for(int i=1;i<n;i++) { int a,b; scanf("%d %d",&a,&b); a--; b--; adj[a].push_back(P(b,i)); adj[b].push_back(P(a,i)); edge[i]=P(a,b); } memset(ont,-1,sizeof(ont)); for(int i=0;i<m;i++) { int x; scanf("%d",&x); if (ont[x]!=-1) { s[x].insert(P(ont[x],i-1)); ont[x]=-1; } else { ont[x]=i; } } for(int i=1;i<n;i++) { if (ont[i]!=-1) { s[i].insert(P(ont[i],m-1)); } } memset(dp,-1,sizeof(dp)); int r; scanf("%d",&r); r--; dp[r]=m; dfs(r,-1); int ret=0; for(int i=0;i<n;i++) { if (dp[i]!=-1) { ret++; } } printf("%d",ret); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8020 KB | Output is correct |
2 | Correct | 4 ms | 8020 KB | Output is correct |
3 | Correct | 6 ms | 8020 KB | Output is correct |
4 | Correct | 5 ms | 8020 KB | Output is correct |
5 | Correct | 5 ms | 8020 KB | Output is correct |
6 | Correct | 5 ms | 8148 KB | Output is correct |
7 | Correct | 15 ms | 9176 KB | Output is correct |
8 | Correct | 13 ms | 9108 KB | Output is correct |
9 | Correct | 11 ms | 9172 KB | Output is correct |
10 | Correct | 118 ms | 18396 KB | Output is correct |
11 | Correct | 96 ms | 18436 KB | Output is correct |
12 | Correct | 73 ms | 22260 KB | Output is correct |
13 | Correct | 86 ms | 18612 KB | Output is correct |
14 | Correct | 91 ms | 17236 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 81 ms | 23300 KB | Output is correct |
2 | Correct | 66 ms | 21440 KB | Output is correct |
3 | Correct | 62 ms | 23792 KB | Output is correct |
4 | Correct | 55 ms | 22776 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 8020 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 83 ms | 25608 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 8120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |