Submission #598873

# Submission time Handle Problem Language Result Execution time Memory
598873 2022-07-19T06:45:07 Z 이동현(#8460) Potemkin cycle (CEOI15_indcyc) C++17
10 / 100
1000 ms 13468 KB
#include <bits/stdc++.h>

using namespace std;

int n, m;
vector<int> way[1004];
int chk[1004];
int stk[1004], stkN, did[1004], didN;

void dfs(int x, int e){
    stk[stkN++] = x; did[x] = didN;
    if(x == e){
        for(int i = 0; i < stkN; ++i){
            cout << stk[i] << ' ';
        }
        exit(0);
    }
    for(auto&nxt:way[x]){
        if(nxt != e && (!chk[nxt] || did[nxt] == didN)) continue;
        dfs(nxt, e);
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    map<pair<int, int>, int> cant;
    for(int i = 1; i <= m; ++i){
        int x, y; cin >> x >> y;
        way[x].push_back(y);
        way[y].push_back(x);
        cant[{x, y}] = cant[{y, x}] = 1;
    }
    for(int i = 1; i <= n; ++i) chk[i] = 1;
    for(int i = 1; i <= n; ++i){
        chk[i] = 0;
        for(auto&nxt:way[i]){
            chk[nxt] = 0;
        }
        for(int j = 0; j < (int)way[i].size(); ++j){
            for(int k = j + 1; k < (int)way[i].size(); ++k){
                if(cant[{way[i][j], way[i][k]}]) continue;
                stk[0] = i;
                stkN = 1; ++didN;
                dfs(way[i][j], way[i][k]);
            }
        }
        chk[i] = 1;
        for(auto&nxt:way[i]){
            chk[nxt] = 1;
        }
    }
    cout << "no\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 134 ms 1012 KB Output is correct
2 Incorrect 2 ms 724 KB Wrong adjacency
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 724 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 542 ms 7432 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 3368 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 601 ms 13468 KB Output is correct
2 Execution timed out 1086 ms 13416 KB Time limit exceeded
3 Halted 0 ms 0 KB -