# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
10720 | 2014-11-09T16:42:02 Z | dohyun0324 | Senior Postmen (BOI14_postmen) | C++ | 444 ms | 46888 KB |
#include<stdio.h> #include<algorithm> using namespace std; int p,n,m,pos[500010],chv[500010],dap[500010],top,cnt,w,che[500010]; struct data { int x,y,z; bool operator<(const data&r)const { return x<r.x; } }arr[1000010]; void dfs(int x) { int i,j; chv[x]=cnt; for(i=pos[x];;i++) { if(p) { dap[++top]=x; if(x==p) { for(j=1;j<=top;j++) printf("%d ",dap[j]); printf("\n"); p=0; } else { chv[x]=0; break; } } if(arr[i].x!=x) break; if(che[arr[i].z]) continue; che[arr[i].z]=1; if(chv[arr[i].y]==cnt) { p=arr[i].y; top=0; dap[++top]=x; i++; chv[x]=0; break; } dfs(arr[i].y); } pos[x]=i; } int main() { int i,j,x,y; scanf("%d %d",&n,&m); for(i=1;i<=m;i++) { scanf("%d %d",&x,&y); w++; arr[w].x=x; arr[w].y=y; arr[w].z=i; w++; arr[w].x=y; arr[w].y=x; arr[w].z=i; } sort(arr+1,arr+w+1); for(i=1;i<=w;i++) { if(arr[i].x!=arr[i-1].x) pos[arr[i].x]=i; } for(i=1;i<=n;i++) { while(arr[pos[i]].x==i) { p=0; cnt++; dfs(i); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 8 ms | 384 KB | Output is correct |
5 | Correct | 6 ms | 384 KB | Output is correct |
6 | Correct | 7 ms | 512 KB | Output is correct |
7 | Correct | 12 ms | 768 KB | Output is correct |
8 | Correct | 6 ms | 512 KB | Output is correct |
9 | Correct | 57 ms | 3416 KB | Output is correct |
10 | Correct | 6 ms | 512 KB | Output is correct |
11 | Correct | 7 ms | 512 KB | Output is correct |
12 | Correct | 59 ms | 3576 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 7 ms | 512 KB | Output is correct |
7 | Correct | 12 ms | 768 KB | Output is correct |
8 | Correct | 6 ms | 512 KB | Output is correct |
9 | Correct | 57 ms | 3576 KB | Output is correct |
10 | Correct | 6 ms | 384 KB | Output is correct |
11 | Correct | 7 ms | 512 KB | Output is correct |
12 | Correct | 72 ms | 3576 KB | Output is correct |
13 | Correct | 87 ms | 9588 KB | Output is correct |
14 | Correct | 71 ms | 4216 KB | Output is correct |
15 | Correct | 83 ms | 4152 KB | Output is correct |
16 | Correct | 70 ms | 9464 KB | Output is correct |
17 | Correct | 89 ms | 4192 KB | Output is correct |
18 | Correct | 67 ms | 5496 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 7 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 8 ms | 512 KB | Output is correct |
7 | Correct | 12 ms | 768 KB | Output is correct |
8 | Correct | 6 ms | 512 KB | Output is correct |
9 | Correct | 61 ms | 3452 KB | Output is correct |
10 | Correct | 6 ms | 512 KB | Output is correct |
11 | Correct | 6 ms | 500 KB | Output is correct |
12 | Correct | 66 ms | 3576 KB | Output is correct |
13 | Correct | 71 ms | 9592 KB | Output is correct |
14 | Correct | 67 ms | 4320 KB | Output is correct |
15 | Correct | 66 ms | 4088 KB | Output is correct |
16 | Correct | 71 ms | 9592 KB | Output is correct |
17 | Correct | 88 ms | 4248 KB | Output is correct |
18 | Correct | 80 ms | 5496 KB | Output is correct |
19 | Correct | 380 ms | 46888 KB | Output is correct |
20 | Correct | 364 ms | 20448 KB | Output is correct |
21 | Correct | 363 ms | 19300 KB | Output is correct |
22 | Correct | 400 ms | 46804 KB | Output is correct |
23 | Correct | 295 ms | 15908 KB | Output is correct |
24 | Correct | 444 ms | 20012 KB | Output is correct |
25 | Correct | 369 ms | 26744 KB | Output is correct |