# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
945675 | 2024-03-14T06:17:15 Z | vjudge1 | Amusement Park (CEOI19_amusementpark) | C++17 | 3000 ms | 483676 KB |
#include <bits/stdc++.h> #define int long long #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back using namespace std; vector <int> g[20]; int cl[20]; bool ok=1; void dfs(int v){ cl[v]=1; for(auto to : g[v]){ if(cl[to]==0)dfs(to); else if(cl[to]==1)ok=0; } cl[v]=2; } signed main(){ int n,m; cin>>n>>m; vector <int> u(m),v(m); for(int i=0;i<m;i++){ cin>>u[i]>>v[i]; } vector <int> ord; vector <vector <int> > st; for(int i=1;i<=n;i++)ord.pb(i); do{ vector <int> val_ord(n+1); for(int i=1;i<=n;i++){ cl[i]=0; g[i].clear(); } ok=1; for(int i=0;i<ord.size();i++){ val_ord[ord[i]]=i; } int cnt=0; vector <int> ch; for(int i=0;i<m;i++){ int x=val_ord[u[i]]; int y=val_ord[v[i]]; if(x<y){ ch.pb(i); g[v[i]].pb(u[i]); } else g[u[i]].pb(v[i]); } for(int i=1;i<=n;i++){ if(!cl[i])dfs(i); if(!ok)break; } if(ok){ st.pb(ch); } }while(next_permutation(all(ord))); int ans=0; sort(all(st)); if(st.size()!=0)ans+=st[0].size(); for(int i=1;i<st.size();i++){ if(st[i].size()!=st[i-1].size())ans+=st[i].size(); else{ for(int j=0;j<st[i].size();j++){ if(st[i][j]!=st[i-1][j]){ ans+=st[i].size();break; } } } } cout<<ans<<"\n"; } /* 3 3 1 2 2 3 1 3 1 2 3 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 432 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 432 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 768 KB | Output is correct |
26 | Correct | 2 ms | 604 KB | Output is correct |
27 | Correct | 2 ms | 856 KB | Output is correct |
28 | Correct | 3 ms | 860 KB | Output is correct |
29 | Correct | 3 ms | 860 KB | Output is correct |
30 | Correct | 3 ms | 860 KB | Output is correct |
31 | Correct | 4 ms | 860 KB | Output is correct |
32 | Correct | 10 ms | 2836 KB | Output is correct |
33 | Correct | 14 ms | 3332 KB | Output is correct |
34 | Correct | 18 ms | 3856 KB | Output is correct |
35 | Correct | 22 ms | 4372 KB | Output is correct |
36 | Correct | 27 ms | 5032 KB | Output is correct |
37 | Correct | 28 ms | 5836 KB | Output is correct |
38 | Correct | 30 ms | 6160 KB | Output is correct |
39 | Correct | 99 ms | 22064 KB | Output is correct |
40 | Correct | 145 ms | 25580 KB | Output is correct |
41 | Correct | 189 ms | 31136 KB | Output is correct |
42 | Correct | 222 ms | 37036 KB | Output is correct |
43 | Correct | 260 ms | 42408 KB | Output is correct |
44 | Correct | 294 ms | 47856 KB | Output is correct |
45 | Correct | 325 ms | 53528 KB | Output is correct |
46 | Correct | 375 ms | 60136 KB | Output is correct |
47 | Correct | 377 ms | 65404 KB | Output is correct |
48 | Correct | 152 ms | 26512 KB | Output is correct |
49 | Correct | 207 ms | 35284 KB | Output is correct |
50 | Correct | 230 ms | 35308 KB | Output is correct |
51 | Correct | 212 ms | 34596 KB | Output is correct |
52 | Correct | 1321 ms | 210824 KB | Output is correct |
53 | Correct | 1851 ms | 272372 KB | Output is correct |
54 | Correct | 2449 ms | 342996 KB | Output is correct |
55 | Correct | 2879 ms | 414036 KB | Output is correct |
56 | Execution timed out | 3077 ms | 483676 KB | Time limit exceeded |
57 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 432 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 768 KB | Output is correct |
26 | Correct | 2 ms | 604 KB | Output is correct |
27 | Correct | 2 ms | 856 KB | Output is correct |
28 | Correct | 3 ms | 860 KB | Output is correct |
29 | Correct | 3 ms | 860 KB | Output is correct |
30 | Correct | 3 ms | 860 KB | Output is correct |
31 | Correct | 4 ms | 860 KB | Output is correct |
32 | Correct | 10 ms | 2836 KB | Output is correct |
33 | Correct | 14 ms | 3332 KB | Output is correct |
34 | Correct | 18 ms | 3856 KB | Output is correct |
35 | Correct | 22 ms | 4372 KB | Output is correct |
36 | Correct | 27 ms | 5032 KB | Output is correct |
37 | Correct | 28 ms | 5836 KB | Output is correct |
38 | Correct | 30 ms | 6160 KB | Output is correct |
39 | Correct | 99 ms | 22064 KB | Output is correct |
40 | Correct | 145 ms | 25580 KB | Output is correct |
41 | Correct | 189 ms | 31136 KB | Output is correct |
42 | Correct | 222 ms | 37036 KB | Output is correct |
43 | Correct | 260 ms | 42408 KB | Output is correct |
44 | Correct | 294 ms | 47856 KB | Output is correct |
45 | Correct | 325 ms | 53528 KB | Output is correct |
46 | Correct | 375 ms | 60136 KB | Output is correct |
47 | Correct | 377 ms | 65404 KB | Output is correct |
48 | Correct | 152 ms | 26512 KB | Output is correct |
49 | Correct | 207 ms | 35284 KB | Output is correct |
50 | Correct | 230 ms | 35308 KB | Output is correct |
51 | Correct | 212 ms | 34596 KB | Output is correct |
52 | Correct | 1321 ms | 210824 KB | Output is correct |
53 | Correct | 1851 ms | 272372 KB | Output is correct |
54 | Correct | 2449 ms | 342996 KB | Output is correct |
55 | Correct | 2879 ms | 414036 KB | Output is correct |
56 | Execution timed out | 3077 ms | 483676 KB | Time limit exceeded |
57 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 432 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 768 KB | Output is correct |
26 | Correct | 2 ms | 604 KB | Output is correct |
27 | Correct | 2 ms | 856 KB | Output is correct |
28 | Correct | 3 ms | 860 KB | Output is correct |
29 | Correct | 3 ms | 860 KB | Output is correct |
30 | Correct | 3 ms | 860 KB | Output is correct |
31 | Correct | 4 ms | 860 KB | Output is correct |
32 | Correct | 10 ms | 2836 KB | Output is correct |
33 | Correct | 14 ms | 3332 KB | Output is correct |
34 | Correct | 18 ms | 3856 KB | Output is correct |
35 | Correct | 22 ms | 4372 KB | Output is correct |
36 | Correct | 27 ms | 5032 KB | Output is correct |
37 | Correct | 28 ms | 5836 KB | Output is correct |
38 | Correct | 30 ms | 6160 KB | Output is correct |
39 | Correct | 99 ms | 22064 KB | Output is correct |
40 | Correct | 145 ms | 25580 KB | Output is correct |
41 | Correct | 189 ms | 31136 KB | Output is correct |
42 | Correct | 222 ms | 37036 KB | Output is correct |
43 | Correct | 260 ms | 42408 KB | Output is correct |
44 | Correct | 294 ms | 47856 KB | Output is correct |
45 | Correct | 325 ms | 53528 KB | Output is correct |
46 | Correct | 375 ms | 60136 KB | Output is correct |
47 | Correct | 377 ms | 65404 KB | Output is correct |
48 | Correct | 152 ms | 26512 KB | Output is correct |
49 | Correct | 207 ms | 35284 KB | Output is correct |
50 | Correct | 230 ms | 35308 KB | Output is correct |
51 | Correct | 212 ms | 34596 KB | Output is correct |
52 | Correct | 1321 ms | 210824 KB | Output is correct |
53 | Correct | 1851 ms | 272372 KB | Output is correct |
54 | Correct | 2449 ms | 342996 KB | Output is correct |
55 | Correct | 2879 ms | 414036 KB | Output is correct |
56 | Execution timed out | 3077 ms | 483676 KB | Time limit exceeded |
57 | Halted | 0 ms | 0 KB | - |