# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
850295 | 2023-09-16T09:38:02 Z | alexdd | Amusement Park (JOI17_amusement_park) | C++17 | 22 ms | 5744 KB |
#include "Joi.h" #include<bits/stdc++.h> using namespace std; static bool visited[10005]; static bool visited2[10005]; static vector<int> ord; static vector<int> con[10005]; static bool done[10005]; static int maxd[10005]; static int siz[10005]; static int parent[10005]; static int subtask; static bool cmp(int x, int y) { if(siz[x]<siz[y]) return 1; if(siz[x]>siz[y]) return 0; if(maxd[x]<maxd[y]) return 1; if(maxd[x]>maxd[y]) return 0; return x<y; } static void dfs_init(int nod) { visited2[nod]=1; siz[nod]=1; maxd[nod]=1; for(auto adj:con[nod]) { if(!visited2[adj]) { parent[adj]=nod; dfs_init(adj); maxd[nod]=max(maxd[nod],maxd[adj]+1); siz[nod]+=siz[adj]; } } } static void dfs(int nod) { visited[nod]=1; sort(con[nod].begin(),con[nod].end(),cmp); ord.push_back(nod); for(auto adj:con[nod]) { if(!visited[adj]) { dfs(adj); ord.push_back(nod); } } } void Joi(int N, int M, int A[], int B[], long long X, int T) { if(T==5 && N>=240) T=4; subtask=T; ord.clear(); for(int i=0;i<N;i++) { visited[i]=0; visited2[i]=0; con[i].clear(); done[i]=0; } for(int i=0;i<M;i++) { con[A[i]].push_back(B[i]); con[B[i]].push_back(A[i]); } if(T!=5) { dfs_init(0); dfs(0); } else { for(int root=0;root<N;root++) { for(int i=0;i<N;i++) { visited[i]=0; visited2[i]=0; } dfs_init(root); dfs(root); if(root+1<N) { vector<int> cv; int cur=root+1; while(cur!=root) { cv.push_back(cur); cur=parent[cur]; } for(int i=cv.size()-1;i>0;i--) { ord.push_back(cv[i]); } } } } int cnt=0; for(int i=0;i<(int)ord.size();i++) { if(!done[ord[i]]) { if(((1LL<<cnt)&X)) MessageBoard(ord[i],1); else MessageBoard(ord[i],0); cnt=(cnt+1)%60; done[ord[i]]=1; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1548 KB | Output is correct |
2 | Correct | 1 ms | 1556 KB | Output is correct |
3 | Correct | 2 ms | 1564 KB | Output is correct |
4 | Correct | 1 ms | 1560 KB | Output is correct |
5 | Correct | 1 ms | 1560 KB | Output is correct |
6 | Correct | 2 ms | 1556 KB | Output is correct |
7 | Correct | 2 ms | 1560 KB | Output is correct |
8 | Correct | 2 ms | 1548 KB | Output is correct |
9 | Correct | 2 ms | 1552 KB | Output is correct |
10 | Correct | 1 ms | 1548 KB | Output is correct |
11 | Correct | 4 ms | 1856 KB | Output is correct |
12 | Correct | 0 ms | 1548 KB | Output is correct |
13 | Correct | 2 ms | 1564 KB | Output is correct |
14 | Correct | 2 ms | 1564 KB | Output is correct |
15 | Correct | 2 ms | 1552 KB | Output is correct |
16 | Correct | 2 ms | 1564 KB | Output is correct |
17 | Correct | 2 ms | 1564 KB | Output is correct |
18 | Correct | 2 ms | 1560 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 5744 KB | Output is correct |
2 | Correct | 19 ms | 5724 KB | Output is correct |
3 | Correct | 22 ms | 5740 KB | Output is correct |
4 | Correct | 12 ms | 3804 KB | Output is correct |
5 | Correct | 12 ms | 4588 KB | Output is correct |
6 | Correct | 13 ms | 4588 KB | Output is correct |
7 | Correct | 12 ms | 4576 KB | Output is correct |
8 | Correct | 13 ms | 4580 KB | Output is correct |
9 | Correct | 12 ms | 4476 KB | Output is correct |
10 | Correct | 14 ms | 4072 KB | Output is correct |
11 | Correct | 15 ms | 4432 KB | Output is correct |
12 | Correct | 10 ms | 3792 KB | Output is correct |
13 | Correct | 10 ms | 3792 KB | Output is correct |
14 | Correct | 11 ms | 3808 KB | Output is correct |
15 | Correct | 12 ms | 3816 KB | Output is correct |
16 | Correct | 12 ms | 3812 KB | Output is correct |
17 | Correct | 12 ms | 3808 KB | Output is correct |
18 | Correct | 14 ms | 4060 KB | Output is correct |
19 | Correct | 13 ms | 3808 KB | Output is correct |
20 | Correct | 12 ms | 4572 KB | Output is correct |
21 | Correct | 10 ms | 4580 KB | Output is correct |
22 | Correct | 11 ms | 4320 KB | Output is correct |
23 | Correct | 13 ms | 4588 KB | Output is correct |
24 | Correct | 12 ms | 4576 KB | Output is correct |
25 | Correct | 12 ms | 4576 KB | Output is correct |
26 | Correct | 12 ms | 4588 KB | Output is correct |
27 | Correct | 12 ms | 4524 KB | Output is correct |
28 | Correct | 12 ms | 4584 KB | Output is correct |
29 | Correct | 10 ms | 4464 KB | Output is correct |
30 | Correct | 11 ms | 4576 KB | Output is correct |
31 | Correct | 0 ms | 1548 KB | Output is correct |
32 | Correct | 1 ms | 1548 KB | Output is correct |
33 | Correct | 2 ms | 1552 KB | Output is correct |
34 | Correct | 1 ms | 1548 KB | Output is correct |
35 | Correct | 0 ms | 1552 KB | Output is correct |
36 | Correct | 1 ms | 1560 KB | Output is correct |
37 | Correct | 0 ms | 1560 KB | Output is correct |
38 | Correct | 2 ms | 1556 KB | Output is correct |
39 | Correct | 1 ms | 1548 KB | Output is correct |
40 | Correct | 1 ms | 1548 KB | Output is correct |
41 | Correct | 1 ms | 1552 KB | Output is correct |
42 | Correct | 0 ms | 1560 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1556 KB | Output is correct |
2 | Correct | 0 ms | 1560 KB | Output is correct |
3 | Correct | 1 ms | 1560 KB | Output is correct |
4 | Correct | 2 ms | 2100 KB | Output is correct |
5 | Correct | 2 ms | 2100 KB | Output is correct |
6 | Correct | 2 ms | 2096 KB | Output is correct |
7 | Correct | 2 ms | 2104 KB | Output is correct |
8 | Correct | 2 ms | 2092 KB | Output is correct |
9 | Correct | 10 ms | 5344 KB | Output is correct |
10 | Correct | 11 ms | 5360 KB | Output is correct |
11 | Correct | 11 ms | 5356 KB | Output is correct |
12 | Correct | 0 ms | 1560 KB | Output is correct |
13 | Correct | 6 ms | 1556 KB | Output is correct |
14 | Correct | 2 ms | 1548 KB | Output is correct |
15 | Correct | 0 ms | 1548 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 5732 KB | Output is correct |
2 | Correct | 19 ms | 5724 KB | Output is correct |
3 | Correct | 22 ms | 5744 KB | Output is correct |
4 | Correct | 13 ms | 3812 KB | Output is correct |
5 | Correct | 13 ms | 5060 KB | Output is correct |
6 | Correct | 12 ms | 4592 KB | Output is correct |
7 | Correct | 12 ms | 4580 KB | Output is correct |
8 | Correct | 12 ms | 4244 KB | Output is correct |
9 | Correct | 12 ms | 4496 KB | Output is correct |
10 | Correct | 14 ms | 4060 KB | Output is correct |
11 | Correct | 12 ms | 4068 KB | Output is correct |
12 | Correct | 11 ms | 3696 KB | Output is correct |
13 | Correct | 11 ms | 3792 KB | Output is correct |
14 | Correct | 11 ms | 3804 KB | Output is correct |
15 | Correct | 12 ms | 3904 KB | Output is correct |
16 | Correct | 11 ms | 3808 KB | Output is correct |
17 | Correct | 12 ms | 3808 KB | Output is correct |
18 | Correct | 12 ms | 3808 KB | Output is correct |
19 | Correct | 12 ms | 3820 KB | Output is correct |
20 | Correct | 10 ms | 4628 KB | Output is correct |
21 | Correct | 11 ms | 4576 KB | Output is correct |
22 | Correct | 14 ms | 4584 KB | Output is correct |
23 | Correct | 12 ms | 4592 KB | Output is correct |
24 | Correct | 12 ms | 4584 KB | Output is correct |
25 | Correct | 12 ms | 4580 KB | Output is correct |
26 | Correct | 12 ms | 4576 KB | Output is correct |
27 | Correct | 15 ms | 5080 KB | Output is correct |
28 | Correct | 12 ms | 4320 KB | Output is correct |
29 | Correct | 12 ms | 4240 KB | Output is correct |
30 | Correct | 11 ms | 4576 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 5736 KB | Output is correct |
2 | Correct | 20 ms | 5744 KB | Output is correct |
3 | Correct | 20 ms | 5740 KB | Output is correct |
4 | Correct | 12 ms | 3820 KB | Output is correct |
5 | Correct | 13 ms | 5352 KB | Output is correct |
6 | Correct | 12 ms | 4496 KB | Output is correct |
7 | Correct | 12 ms | 4328 KB | Output is correct |
8 | Correct | 15 ms | 4704 KB | Output is correct |
9 | Correct | 12 ms | 4576 KB | Output is correct |
10 | Correct | 15 ms | 4056 KB | Output is correct |
11 | Correct | 12 ms | 4068 KB | Output is correct |
12 | Correct | 10 ms | 3792 KB | Output is correct |
13 | Correct | 11 ms | 3788 KB | Output is correct |
14 | Correct | 11 ms | 3844 KB | Output is correct |
15 | Correct | 11 ms | 3808 KB | Output is correct |
16 | Correct | 11 ms | 3816 KB | Output is correct |
17 | Correct | 15 ms | 3800 KB | Output is correct |
18 | Correct | 11 ms | 3824 KB | Output is correct |
19 | Correct | 12 ms | 3808 KB | Output is correct |
20 | Correct | 13 ms | 4828 KB | Output is correct |
21 | Correct | 10 ms | 4580 KB | Output is correct |
22 | Correct | 13 ms | 4584 KB | Output is correct |
23 | Correct | 12 ms | 4584 KB | Output is correct |
24 | Correct | 12 ms | 4576 KB | Output is correct |
25 | Correct | 11 ms | 4588 KB | Output is correct |
26 | Correct | 14 ms | 4332 KB | Output is correct |
27 | Correct | 14 ms | 4568 KB | Output is correct |
28 | Correct | 12 ms | 4588 KB | Output is correct |
29 | Correct | 11 ms | 4572 KB | Output is correct |
30 | Correct | 14 ms | 4808 KB | Output is correct |
31 | Correct | 3 ms | 2708 KB | Output is correct |
32 | Runtime error | 5 ms | 4244 KB | Execution killed with signal 11 |
33 | Halted | 0 ms | 0 KB | - |