# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
102604 | 2019-03-26T07:48:34 Z | username | 통행료 (IOI18_highway) | C++14 | 356 ms | 15676 KB |
#include<bits/stdc++.h> #include "highway.h" using namespace std; typedef pair<int,int> pii; typedef vector<int> VI; #define REP(i,j,k) for(register int i=(j);i<(k);++i) #define RREP(i,j,k) for(register int i=(j)-1;i>=(k);--i) #define ALL(a) a.begin(),a.end() #define MST(a,v) memset(a,(v),sizeof a) #define pb push_back #define mid (l+r>>1) const int maxn=9e4+9,inf=1<<30; int n,m,d1[maxn],d2[maxn],p1[maxn],p2[maxn]; long long o; vector<pii>G[maxn]; VI g1[maxn],g2[maxn],w; queue<int>Q; void bfs(int s,int*dis,int*par){ fill(dis,dis+n,inf); dis[s]=0; Q.push(s); while(!Q.empty()){ int u=Q.front();Q.pop(); REP(i,0,G[u].size()){ int v=G[u][i].first; if(dis[v]>dis[u]+1){ dis[v]=dis[u]+1; par[v]=G[u][i].second; Q.push(v); } } } } int find(VI&vt,int*par){ int l=0,r=vt.size(); while(l+1<r){ REP(i,1,mid)w[par[vt[i]]]=0; REP(i,mid,vt.size())w[par[vt[i]]]=1; if(ask(w)>o)l=mid; else r=mid; } return vt[l]; } void find_pair(int _n,VI uu,VI vv,int a,int b){ n=_n; m=uu.size(); w.resize(m); REP(i,0,m)w[i]=0; o=ask(w); int l=0,r=m; while(l+1<r){ REP(i,0,mid)w[i]=0; REP(i,mid,m)w[i]=1; if(ask(w)>o)l=mid; else r=mid; } int ee=l; REP(i,0,m){ int u=uu[i],v=vv[i]; G[u].pb(pii(v,i)),G[v].pb(pii(u,i)); } bfs(uu[ee],d1,p1); bfs(vv[ee],d2,p2); VI v1,v2; REP(i,0,n){ if(d1[i]<d2[i])v1.pb(i); else v2.pb(i); } sort(ALL(v1),[](int x,int y){return d1[x]<d1[y];}); sort(ALL(v2),[](int x,int y){return d2[x]<d2[y];}); REP(i,0,m)w[i]=1; w[ee]=0; REP(i,1,v1.size())w[p1[v1[i]]]=0; REP(i,1,v2.size())w[p2[v2[i]]]=0; int u=find(v1,p1); REP(i,0,m)w[i]=1; w[ee]=0; REP(i,1,v1.size())w[p1[v1[i]]]=0; REP(i,1,v2.size())w[p2[v2[i]]]=0; int v=find(v2,p2); answer(u,v); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6648 KB | Output is correct |
2 | Correct | 8 ms | 6668 KB | Output is correct |
3 | Correct | 8 ms | 6568 KB | Output is correct |
4 | Correct | 7 ms | 6668 KB | Output is correct |
5 | Correct | 8 ms | 6624 KB | Output is correct |
6 | Correct | 8 ms | 6648 KB | Output is correct |
7 | Correct | 7 ms | 6668 KB | Output is correct |
8 | Correct | 8 ms | 6668 KB | Output is correct |
9 | Correct | 8 ms | 6700 KB | Output is correct |
10 | Correct | 7 ms | 6648 KB | Output is correct |
11 | Correct | 8 ms | 6648 KB | Output is correct |
12 | Correct | 7 ms | 6648 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6688 KB | Output is correct |
2 | Correct | 29 ms | 7544 KB | Output is correct |
3 | Correct | 227 ms | 13848 KB | Output is correct |
4 | Correct | 232 ms | 13860 KB | Output is correct |
5 | Correct | 232 ms | 13856 KB | Output is correct |
6 | Correct | 227 ms | 13832 KB | Output is correct |
7 | Correct | 229 ms | 13848 KB | Output is correct |
8 | Correct | 222 ms | 13836 KB | Output is correct |
9 | Correct | 237 ms | 13956 KB | Output is correct |
10 | Correct | 220 ms | 13844 KB | Output is correct |
11 | Correct | 241 ms | 13156 KB | Output is correct |
12 | Correct | 244 ms | 13300 KB | Output is correct |
13 | Correct | 256 ms | 13208 KB | Output is correct |
14 | Correct | 224 ms | 13304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 7336 KB | Output is correct |
2 | Correct | 47 ms | 8164 KB | Output is correct |
3 | Correct | 84 ms | 8944 KB | Output is correct |
4 | Correct | 179 ms | 13160 KB | Output is correct |
5 | Correct | 177 ms | 13152 KB | Output is correct |
6 | Correct | 160 ms | 13424 KB | Output is correct |
7 | Correct | 179 ms | 13312 KB | Output is correct |
8 | Correct | 169 ms | 13272 KB | Output is correct |
9 | Correct | 204 ms | 13248 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6772 KB | Output is correct |
2 | Correct | 30 ms | 7416 KB | Output is correct |
3 | Correct | 162 ms | 12468 KB | Output is correct |
4 | Correct | 225 ms | 13832 KB | Output is correct |
5 | Correct | 251 ms | 13760 KB | Output is correct |
6 | Correct | 231 ms | 13832 KB | Output is correct |
7 | Correct | 224 ms | 13860 KB | Output is correct |
8 | Correct | 230 ms | 13768 KB | Output is correct |
9 | Correct | 249 ms | 13708 KB | Output is correct |
10 | Correct | 237 ms | 13908 KB | Output is correct |
11 | Correct | 256 ms | 13304 KB | Output is correct |
12 | Correct | 221 ms | 13300 KB | Output is correct |
13 | Correct | 263 ms | 13156 KB | Output is correct |
14 | Correct | 257 ms | 13176 KB | Output is correct |
15 | Correct | 222 ms | 13784 KB | Output is correct |
16 | Correct | 203 ms | 13852 KB | Output is correct |
17 | Correct | 268 ms | 13300 KB | Output is correct |
18 | Correct | 238 ms | 13304 KB | Output is correct |
19 | Correct | 278 ms | 13880 KB | Output is correct |
20 | Correct | 252 ms | 13296 KB | Output is correct |
21 | Correct | 200 ms | 14428 KB | Output is correct |
22 | Correct | 230 ms | 14436 KB | Output is correct |
23 | Correct | 221 ms | 14252 KB | Output is correct |
24 | Correct | 218 ms | 14164 KB | Output is correct |
25 | Correct | 251 ms | 13308 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 7392 KB | Output is correct |
2 | Correct | 34 ms | 7592 KB | Output is correct |
3 | Correct | 258 ms | 14208 KB | Output is correct |
4 | Correct | 264 ms | 14664 KB | Output is correct |
5 | Correct | 335 ms | 15676 KB | Output is correct |
6 | Correct | 331 ms | 15500 KB | Output is correct |
7 | Correct | 352 ms | 15544 KB | Output is correct |
8 | Correct | 320 ms | 15532 KB | Output is correct |
9 | Correct | 248 ms | 12940 KB | Output is correct |
10 | Correct | 251 ms | 13332 KB | Output is correct |
11 | Correct | 271 ms | 13808 KB | Output is correct |
12 | Correct | 320 ms | 14900 KB | Output is correct |
13 | Correct | 308 ms | 15288 KB | Output is correct |
14 | Correct | 314 ms | 15620 KB | Output is correct |
15 | Correct | 306 ms | 15608 KB | Output is correct |
16 | Correct | 291 ms | 14096 KB | Output is correct |
17 | Correct | 218 ms | 14204 KB | Output is correct |
18 | Correct | 213 ms | 14484 KB | Output is correct |
19 | Correct | 206 ms | 14364 KB | Output is correct |
20 | Correct | 197 ms | 14412 KB | Output is correct |
21 | Correct | 333 ms | 15580 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 7476 KB | Output is correct |
2 | Correct | 30 ms | 7524 KB | Output is correct |
3 | Correct | 237 ms | 14196 KB | Output is correct |
4 | Correct | 297 ms | 14388 KB | Output is correct |
5 | Correct | 321 ms | 14796 KB | Output is correct |
6 | Correct | 328 ms | 15652 KB | Output is correct |
7 | Correct | 265 ms | 14124 KB | Output is correct |
8 | Correct | 285 ms | 14492 KB | Output is correct |
9 | Correct | 258 ms | 14632 KB | Output is correct |
10 | Correct | 337 ms | 15480 KB | Output is correct |
11 | Correct | 333 ms | 15540 KB | Output is correct |
12 | Correct | 336 ms | 15624 KB | Output is correct |
13 | Correct | 269 ms | 13864 KB | Output is correct |
14 | Correct | 239 ms | 13324 KB | Output is correct |
15 | Correct | 221 ms | 13864 KB | Output is correct |
16 | Correct | 251 ms | 13328 KB | Output is correct |
17 | Correct | 242 ms | 13812 KB | Output is correct |
18 | Correct | 239 ms | 13392 KB | Output is correct |
19 | Correct | 314 ms | 14980 KB | Output is correct |
20 | Correct | 329 ms | 15280 KB | Output is correct |
21 | Correct | 331 ms | 15540 KB | Output is correct |
22 | Correct | 339 ms | 15548 KB | Output is correct |
23 | Correct | 356 ms | 15548 KB | Output is correct |
24 | Correct | 334 ms | 15620 KB | Output is correct |
25 | Correct | 316 ms | 15592 KB | Output is correct |
26 | Correct | 332 ms | 15548 KB | Output is correct |
27 | Correct | 233 ms | 14376 KB | Output is correct |
28 | Correct | 201 ms | 14240 KB | Output is correct |
29 | Correct | 213 ms | 14512 KB | Output is correct |
30 | Correct | 216 ms | 14380 KB | Output is correct |
31 | Correct | 218 ms | 14468 KB | Output is correct |
32 | Correct | 204 ms | 14216 KB | Output is correct |
33 | Correct | 235 ms | 14516 KB | Output is correct |
34 | Correct | 217 ms | 14364 KB | Output is correct |
35 | Correct | 215 ms | 14344 KB | Output is correct |
36 | Correct | 218 ms | 14224 KB | Output is correct |
37 | Correct | 230 ms | 14560 KB | Output is correct |
38 | Correct | 215 ms | 14432 KB | Output is correct |
39 | Correct | 351 ms | 15604 KB | Output is correct |
40 | Correct | 354 ms | 15620 KB | Output is correct |
41 | Correct | 332 ms | 15616 KB | Output is correct |
42 | Correct | 354 ms | 15536 KB | Output is correct |