# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
68227 | 2018-08-16T09:11:22 Z | top34051 | 동기화 (JOI13_synchronization) | C++17 | 138 ms | 32044 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<pii> way[maxn]; int open[maxn]; vector<pii> edge[maxn]; int res; int get(int x, int val) { int l = 0, r = edge[x].size(), mid, pos = -1; while(l<=r) { mid = (l+r)/2; if(edge[x][mid].X <= val) { pos = mid; l = mid+1; } else r = mid-1; } if(pos==-1) return 0; return min(val, edge[x][pos].Y); } void solve(int u, int last, int cur) { if(cur==0) return ; // printf("solve %d : %d\n",u,cur); res++; for(auto t : way[u]) { int v = t.X, id = t.Y; if(v==last) continue; solve(v,u,get(id,cur)); } } 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,i}); way[v].push_back({u,i}); } for(int i=1;i<=m;i++) { int x; scanf("%d",&x); if(!open[x]) open[x] = i; else { edge[x].push_back({open[x],i-1}); open[x] = 0; } } for(int x=1;x<n;x++) { if(open[x]) { edge[x].push_back({open[x],m}); } } for(int i=1;i<=q;i++) { int x; scanf("%d",&x); res = 0; solve(x,0,m); printf("%d\n",res); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 9720 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 104 ms | 17264 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 17264 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 138 ms | 32044 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 32044 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |