Submission #143120

# Submission time Handle Problem Language Result Execution time Memory
143120 2019-08-13T05:18:25 Z Ruxandra985 Pipes (CEOI15_pipes) C++14
0 / 100
3030 ms 65540 KB
/// trimit de curiozitate

#include <cstdio>
#include <vector>
#include <set>
#include <stack>
#include <algorithm>
#define DIMN 100005
#define DIMM 100005
using namespace std;
int low[DIMN],bicnx,lvl[DIMN];
stack <int > st;
vector <int> v[DIMN];
set <int> sol[DIMN];
int x;
void dfs (int nod,int tt){
    int i,vecin;
    low[nod]=lvl[nod];
    st.push(nod);
    for (i=0;i<v[nod].size();i++){
        vecin=v[nod][i];
        if (vecin==tt)
            continue;
        if (lvl[vecin]==0){
            lvl[vecin]=1+lvl[nod];
            dfs(vecin,nod);
            low[nod]=min(low[nod],low[vecin]);
            if (low[vecin]>=lvl[nod]){ // nod e un nod critic
                bicnx++;
                do{
                    x=st.top();
                    st.pop();
                    sol[bicnx].insert(x);
                }
                while (x!=vecin);
                sol[bicnx].insert(nod);
                // am scos din stiva muchiile care sunt in subarborele nod->vecin
            }
        }
        else low[nod]=min(low[nod],lvl[vecin]);
    }
}
int main()
{
 //   FILE *fin=fopen ("a.in","r");
  //  FILE *fout=fopen ("a.out","w");
    int n,m,i,x,y;
    scanf ("%d%d",&n,&m);
    for (i=1;i<=m;i++){
        scanf ("%d%d",&x,&y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for (i=1;i<=n;i++){
        if (!lvl[i]){
            lvl[i]=1;
            dfs (i,0);
        }
    }
    for (i=1;i<=bicnx;i++){
        if (sol[i].size()==2){
            for (set <int>::iterator it = sol[i].begin(); it!=sol[i].end();it++)
                printf ("%d ",*it);
            printf ("\n");
        }
    }
    return 0;
}

Compilation message

pipes.cpp: In function 'void dfs(int, int)':
pipes.cpp:20:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i=0;i<v[nod].size();i++){
              ~^~~~~~~~~~~~~~
pipes.cpp: In function 'int main()':
pipes.cpp:48:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d%d",&n,&m);
     ~~~~~~^~~~~~~~~~~~~~
pipes.cpp:50:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d%d",&x,&y);
         ~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Incorrect 9 ms 7416 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 14 ms 8056 KB Output is correct
2 Incorrect 16 ms 7932 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Runtime error 191 ms 20856 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 359 ms 28216 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 678 ms 45604 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1132 ms 55840 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1817 ms 65536 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2359 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2866 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3030 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -