답안 #46957

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
46957 2018-04-25T11:24:38 Z iletavcioski Pipes (CEOI15_pipes) C++17
10 / 100
422 ms 65536 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n,m;
int ind[100001];
int lo[100001];
bool vis[600001];
vector<vector<pair<int,int> > > v;
int broj=1;
void dfs(int x,int pr)
{
    ind[x]=broj;
    lo[x]=broj;
    broj++;
    for(int i=0;i<v[x].size();i++)
    {
        if(v[x][i].second==pr)
            continue;
        if(ind[v[x][i].first]==0)
        {
            dfs(v[x][i].first,v[x][i].second);
            lo[x]=min(lo[x],lo[v[x][i].first]);
            if(lo[v[x][i].first]>ind[x])
                vis[v[x][i].second]=true;
        }
        else
            lo[x]=min(lo[x],ind[v[x][i].first]);
    }
}
int main()
{
    cin>>n;
    cin>>m;
    vector<pair<int,int> > vec;
    vector<int> s,e;
    v.insert(v.begin(),2*(n+m+4),vec);
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        s.push_back(a);
        e.push_back(b);
        v[a].push_back(make_pair(b,i));
        v[b].push_back(make_pair(a,i));
    }
    dfs(0,-1);
    for(int i=0;i<m;i++)
    { 
        if(vis[i])
            cout<<s[i]+1<<" "<<e[i]+1<<endl;
    }
    cout<<endl;
    return 0;
}
/*
9 11
1 2
2 3
3 1
3 4
4 5
5 6
6 4
6 7
7 8
8 9
9 7
*/

Compilation message

pipes.cpp: In function 'void dfs(int, int)':
pipes.cpp:16:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v[x].size();i++)
                 ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1636 KB Wrong number of edges
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 401 ms 50144 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 422 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 59 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 55 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 59 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 67 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 60 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 60 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -