Submission #65496

# Submission time Handle Problem Language Result Execution time Memory
65496 2018-08-07T19:18:11 Z 3zp Potemkin cycle (CEOI15_indcyc) C++14
0 / 100
1000 ms 14120 KB
#include<bits/stdc++.h>
using namespace std;
vector<int> c, v[1009];
int f[1009][1009];
int F[1009];
int G[1009];
int a[1009], b[1009];
void dfs(int x){
    F[x] = 1;
    c.push_back(x);
    for(int i = 0; i < v[x].size(); i++)
        if(!F[v[x][i]]) dfs(v[x][i]);
}
main(){
    int n, m;
    cin >> n >> m;
    for(int i =  1; i <= m; i++){
        cin >> a[i] >> b[i];
        f[a[i]][b[i]] = 1;
        f[b[i]][a[i]] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++)
            F[j] = 0, v[j].clear();
        vector<int> s;
        F[i] = 1;
        for(int j = 1; j <= m; j++){
            int x = a[j], y = b[j];
            if(x == i){
                s.push_back(y);
                F[y] = 2;
                continue;
            }
            if(y == i){
                s.push_back(x);
                F[x] = 2;
                continue;
            }
            if(f[i][x] && f[i][y]) continue;
            v[x].push_back(y);
            v[y].push_back(x);
        }
        for(int j = 1; j <= n; j++){
            if(!F[j]){
                c.clear();
                dfs(j);
                vector<int> g;
                for(int k = 0; k < c.size(); k++){
                    for(int t = 0;  t < v[c[k]].size(); t++){
                        int x = v[c[k]][t];
                        if(G[x] == 0 && F[x] == 2){
                            g.push_back(x);
                            G[x] = 1;
                        }
                    }
                }
                for(int i = 0; i < g.size(); i++)
                    G[g[i]] = 0;
                for(int i1 = 0; i1 < g.size(); i1++){
                    for(int j = i1 + 1; j < g.size(); j++){
                        if(f[g[i1]][g[j]]) continue;
                        cout<<"FOUND"<<endl;
                        cout<<i<<" "<<g[i1]<<" "<<g[j]<<endl;
                        return 0;
                    }
                }
            }

        }
    }
    cout<<"no"<<endl;
}

Compilation message

indcyc.cpp: In function 'void dfs(int)':
indcyc.cpp:11:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v[x].size(); i++)
                    ~~^~~~~~~~~~~~~
indcyc.cpp: At global scope:
indcyc.cpp:14:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
indcyc.cpp: In function 'int main()':
indcyc.cpp:48:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int k = 0; k < c.size(); k++){
                                ~~^~~~~~~~~~
indcyc.cpp:49:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     for(int t = 0;  t < v[c[k]].size(); t++){
                                     ~~^~~~~~~~~~~~~~~~
indcyc.cpp:57:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int i = 0; i < g.size(); i++)
                                ~~^~~~~~~~~~
indcyc.cpp:59:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int i1 = 0; i1 < g.size(); i1++){
                                 ~~~^~~~~~~~~~
indcyc.cpp:60:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     for(int j = i1 + 1; j < g.size(); j++){
                                         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Expected integer, but "FOUND" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Expected integer, but "FOUND" found
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 400 KB Expected integer, but "FOUND" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 916 KB Expected integer, but "FOUND" found
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 916 KB Expected integer, but "FOUND" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2444 KB Output is correct
2 Incorrect 20 ms 2528 KB Expected integer, but "no" found
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 2572 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 14120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 622 ms 14120 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 161 ms 14120 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -