답안 #244460

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
244460 2020-07-04T06:31:30 Z dantoh000 Pipes (CEOI15_pipes) C++14
30 / 100
2980 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
typedef pair<int,int> ii;
int n,m;
vector<int> G[100005];
int num[100005];
int p[100005];
int low[100005];
int ct = 1;
int k[100005];
unordered_map<int,short> M;
int hsh(int u, int v){
    return (k[u]+k[v])%mod;
}

int root;
void dfs(int u){
    low[u] = num[u] = ct++;
    for (auto v : G[u]){
        if (num[v] == 0){
            p[v] = u;
            dfs(v);
            if (low[v] > num[u]){
                if (m >= 15000 || M[hsh(u,v)] == 1){
                    printf("%d %d\n",u,v);
                }
            }
            low[u] = min(low[u],low[v]);
        }
        else if (v != p[u]){
            low[u] = min(low[u],num[v]);
        }
    }
}
int main(){
    scanf("%d%d",&n,&m);
    k[0] = 1;
    for (int i = 1; i <= n; i++){
        k[i] = (k[i-1]*3)%1000000007;
    }
    for (int i = 0; i < m; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        if (u > v) swap(u,v);
        G[u].push_back(v);
        G[v].push_back(u);
        if (m <= 15000) M[hsh(u,v)] = min(2,M[hsh(u,v)]+1);
    }
    for (int i = 1; i <= n; i++){
        if (num[i] == 0){
            dfs(i);
        }
    }
}

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:37: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:44: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 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 3584 KB Output is correct
2 Correct 13 ms 3456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 180 ms 10832 KB Output is correct
2 Correct 178 ms 10104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 326 ms 14456 KB Output is correct
2 Runtime error 391 ms 18820 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 598 ms 25164 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 959 ms 30988 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 1719 ms 52840 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 2260 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 2666 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 2980 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -