Submission #582539

# Submission time Handle Problem Language Result Execution time Memory
582539 2022-06-24T04:45:01 Z 반딧불(#8370) Amusement Park (CEOI19_amusementpark) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, m;
int ex[102], ey[102];
int idx[102];
string s;
bool used[102];

set<string> st;
int ans;

void dfs(int x){
    if(x==n+1){
//        cout << s << endl;
        if(st.find(s) == st.end()){
            st.insert(s);
            int cnt = 0;
            for(int i=1; i<=m; i++){
                if(idx[ex[i]] > idx[ey[i]]) cnt++;
            }
            ans += cnt;
        }
        return;
    }
    for(int i=1; i<=n; i++){
        if(used[i]) continue;
        used[i] = 1;
        idx[i] = x-1;
        s.push_back('0'+i-1);
        dfs(x+1);
        idx[i]=0;
        used[i]=0;
        s.pop_back();
    }
}

int main(){
    scanf("%d %d", &n, &m);
    for(int i=1; i<=m; i++){
        scanf("%d %d", &ex[i], &ey[i]);
    }
    dfs(1);
    printf("%d", ans);
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
amusementpark.cpp:44:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |         scanf("%d %d", &ex[i], &ey[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -