답안 #946426

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
946426 2024-03-14T16:23:57 Z Aiperiii Amusement Park (CEOI19_amusementpark) C++14
19 / 100
3000 ms 217232 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;
    set <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){
            st.insert(ch);
        }
    }while(next_permutation(all(ord)));
    int ans=0;
    for(auto x : st)ans+=x.size();
    cout<<ans<<"\n";
}


/*
 3 3
 1 2
 2 3
 1 3
 1 2 3
*/

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:36:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i=0;i<ord.size();i++){
      |                     ~^~~~~~~~~~~
amusementpark.cpp:40:13: warning: unused variable 'cnt' [-Wunused-variable]
   40 |         int cnt=0;
      |             ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 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 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 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 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 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 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 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 600 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 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 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 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 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 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 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 600 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 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 3 ms 600 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 4 ms 1116 KB Output is correct
32 Correct 6 ms 428 KB Output is correct
33 Correct 9 ms 344 KB Output is correct
34 Correct 13 ms 604 KB Output is correct
35 Correct 20 ms 856 KB Output is correct
36 Correct 22 ms 2008 KB Output is correct
37 Correct 35 ms 4164 KB Output is correct
38 Correct 47 ms 7764 KB Output is correct
39 Correct 57 ms 344 KB Output is correct
40 Correct 82 ms 428 KB Output is correct
41 Correct 105 ms 348 KB Output is correct
42 Correct 143 ms 1116 KB Output is correct
43 Correct 184 ms 4692 KB Output is correct
44 Correct 197 ms 9296 KB Output is correct
45 Correct 276 ms 22184 KB Output is correct
46 Correct 324 ms 45200 KB Output is correct
47 Correct 425 ms 78640 KB Output is correct
48 Correct 79 ms 432 KB Output is correct
49 Correct 123 ms 1164 KB Output is correct
50 Correct 145 ms 844 KB Output is correct
51 Correct 125 ms 828 KB Output is correct
52 Correct 616 ms 344 KB Output is correct
53 Correct 905 ms 592 KB Output is correct
54 Correct 1206 ms 1360 KB Output is correct
55 Correct 1518 ms 5592 KB Output is correct
56 Correct 1923 ms 31652 KB Output is correct
57 Correct 2414 ms 91852 KB Output is correct
58 Execution timed out 3051 ms 217232 KB Time limit exceeded
59 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 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 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 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 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 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 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 600 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 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 3 ms 600 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 4 ms 1116 KB Output is correct
32 Correct 6 ms 428 KB Output is correct
33 Correct 9 ms 344 KB Output is correct
34 Correct 13 ms 604 KB Output is correct
35 Correct 20 ms 856 KB Output is correct
36 Correct 22 ms 2008 KB Output is correct
37 Correct 35 ms 4164 KB Output is correct
38 Correct 47 ms 7764 KB Output is correct
39 Correct 57 ms 344 KB Output is correct
40 Correct 82 ms 428 KB Output is correct
41 Correct 105 ms 348 KB Output is correct
42 Correct 143 ms 1116 KB Output is correct
43 Correct 184 ms 4692 KB Output is correct
44 Correct 197 ms 9296 KB Output is correct
45 Correct 276 ms 22184 KB Output is correct
46 Correct 324 ms 45200 KB Output is correct
47 Correct 425 ms 78640 KB Output is correct
48 Correct 79 ms 432 KB Output is correct
49 Correct 123 ms 1164 KB Output is correct
50 Correct 145 ms 844 KB Output is correct
51 Correct 125 ms 828 KB Output is correct
52 Correct 616 ms 344 KB Output is correct
53 Correct 905 ms 592 KB Output is correct
54 Correct 1206 ms 1360 KB Output is correct
55 Correct 1518 ms 5592 KB Output is correct
56 Correct 1923 ms 31652 KB Output is correct
57 Correct 2414 ms 91852 KB Output is correct
58 Execution timed out 3051 ms 217232 KB Time limit exceeded
59 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 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 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 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 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 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 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 600 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 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 3 ms 600 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 4 ms 1116 KB Output is correct
32 Correct 6 ms 428 KB Output is correct
33 Correct 9 ms 344 KB Output is correct
34 Correct 13 ms 604 KB Output is correct
35 Correct 20 ms 856 KB Output is correct
36 Correct 22 ms 2008 KB Output is correct
37 Correct 35 ms 4164 KB Output is correct
38 Correct 47 ms 7764 KB Output is correct
39 Correct 57 ms 344 KB Output is correct
40 Correct 82 ms 428 KB Output is correct
41 Correct 105 ms 348 KB Output is correct
42 Correct 143 ms 1116 KB Output is correct
43 Correct 184 ms 4692 KB Output is correct
44 Correct 197 ms 9296 KB Output is correct
45 Correct 276 ms 22184 KB Output is correct
46 Correct 324 ms 45200 KB Output is correct
47 Correct 425 ms 78640 KB Output is correct
48 Correct 79 ms 432 KB Output is correct
49 Correct 123 ms 1164 KB Output is correct
50 Correct 145 ms 844 KB Output is correct
51 Correct 125 ms 828 KB Output is correct
52 Correct 616 ms 344 KB Output is correct
53 Correct 905 ms 592 KB Output is correct
54 Correct 1206 ms 1360 KB Output is correct
55 Correct 1518 ms 5592 KB Output is correct
56 Correct 1923 ms 31652 KB Output is correct
57 Correct 2414 ms 91852 KB Output is correct
58 Execution timed out 3051 ms 217232 KB Time limit exceeded
59 Halted 0 ms 0 KB -