Submission #244506

# Submission time Handle Problem Language Result Execution time Memory
244506 2020-07-04T08:08:07 Z dantoh000 Pipes (CEOI15_pipes) C++14
10 / 100
5000 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
typedef pair<int,int> ii;
int n,m;
unordered_set<int> bad;
int num[100005];
int p[100005];
int low[100005];
int ct = 1;
int k[100005];
unordered_set<int> G;
int hsh(int u, int v){
    return (k[u]+k[v])%mod;
}
void dfs(int u){
    low[u] = num[u] = ct++;
    for (int v = 1; v <= n; v++){
        if (G.find(hsh(u,v)) != G.end()){
            if (num[v] == 0){
                p[v] = u;
                dfs(v);
                if (low[v] > num[u]){
                    if (bad.find(hsh(u,v)) == bad.end()){
                        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);
        int K = hsh(u,v);
        if (G.find(K) != G.end()) bad.insert(K);
        else G.insert(K);
    }
    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);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 771 ms 1200 KB Wrong number of edges
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1744 ms 26964 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 Execution timed out 5101 ms 50384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5095 ms 62184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1266 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 1288 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 1276 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 1357 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 1283 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -