답안 #244461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
244461 2020-07-04T06:32:10 Z tqbfjotld Pipes (CEOI15_pipes) C++14
20 / 100
1590 ms 65540 KB
///lib code still allowed right
#include <bits/stdc++.h>
using namespace std;

int low[100005];
int order[100005];
int cur = 1;
bool visited[100005];
vector<pair<int,int> > adjl[100005]; ///(node,id)
int root = 0;

///ensure no duplicate edges first though
void dfs(int node, int pEdge){
    order[node] = cur;
    cur++;
    visited[node] = true;
    low[node] = order[node];
    for (auto x : adjl[node]){
        if (!visited[x.first]){
            dfs(x.first,x.second);
            if (low[node]==-1 || (low[x.first]!=-1 && low[x.first]<low[node])){
                low[node] = low[x.first];
            }
            if (node!=root){
                if (low[x.first]==-1 || low[x.first]>=order[node]){
                }
            }
            else{
            }
        }
        else if (x.second!=pEdge){
            if (low[node]==-1 || order[x.first]<low[node]) low[node] = order[x.first];
        }
    }
}
//ans is number of components after removing node (>1 if is articulation point)
//bridge break a component if it is removed
//HAVE NOT TESTED YET (but should be correct though)
inline bool isBridge(int a, int b){
    if (order[b]<order[a]) swap(a,b);
    return low[b]>order[a];
}

int n,e;


int main(){
    scanf("%d%d",&n,&e);
    for (int x = 0; x<e; x++){
        int a,b;
        scanf("%d%d",&a,&b);
        a--;b--;
        adjl[a].push_back({b,x});
        adjl[b].push_back({a,x});
    }

    memset(low,-1,sizeof(low));
    for (root = 0; root<n; root++){
        if (!visited[root]) dfs(root,-1);
    }
    for (int x = 0; x<n; x++){
        //printf("%d: order: %d, low: %d\n",1+x,order[x],low[x]);
    }
    for (int x = 0; x<n; x++){
        for (auto y : adjl[x]){
            if (y.first<x){
                if (isBridge(x,y.first)){
                    printf("%d %d\n",x+1,y.first+1);
                }
            }
        }
    }

}



Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&e);
     ~~~~~^~~~~~~~~~~~~~
pipes.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&a,&b);
         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3072 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 3584 KB Output is correct
2 Correct 11 ms 3456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 221 ms 18860 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 366 ms 24584 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 685 ms 44316 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 1100 ms 48692 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 1344 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1586 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1590 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1522 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -