답안 #244510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
244510 2020-07-04T08:19:25 Z dantoh000 Pipes (CEOI15_pipes) C++14
20 / 100
1506 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int n,m;
unordered_map<int,bool> M[30005];
int num[30005];
int p[30005];
int low[30005];
int ct = 1;
void dfs(int u){
    low[u] = num[u] = ct++;
    for (auto v : M[u]){
        if (num[v.first] == 0){
            p[v.first] = u;
            dfs(v.first);
            if (low[v.first] > num[u]){
                if (v.second == 0){
                    printf("%d %d\n",u,v);
                }
            }
            low[u] = min(low[u],low[v.first]);
        }
        else if (v.first != p[u]){
            low[u] = min(low[u],num[v.first]);
        }
    }
}
int main(){
    scanf("%d%d",&n,&m);
    for (int i = 0; i < m; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        if (u > v) swap(u,v);
        if (M[u].count(v)){
            M[u][v] = 1;
        }
        else{
            M[u][v] = 0;
        }
    }
    for (int u = 1; u <= n; u++){
        for (auto v : M[u]){
            M[v.first][u] = v.second;
        }
    }
    for (int i = 1; i <= n; i++){
        if (num[i] == 0){
            dfs(i);
        }
    }
}

Compilation message

pipes.cpp: In function 'void dfs(int)':
pipes.cpp:18:41: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::pair<const int, bool>' [-Wformat=]
                     printf("%d %d\n",u,v);
                                         ^
pipes.cpp: In function 'int main()':
pipes.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
pipes.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&u,&v);
         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2048 KB Output is correct
2 Correct 6 ms 1920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 3200 KB Output is correct
2 Correct 14 ms 3072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1444 ms 49504 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 1357 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 1506 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 8 ms 3840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 3712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 3712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 3712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 3712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -