Submission #244458

# Submission time Handle Problem Language Result Execution time Memory
244458 2020-07-04T06:30:26 Z dantoh000 Pipes (CEOI15_pipes) C++14
20 / 100
1288 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[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);
        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);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 3584 KB Output is correct
2 Correct 12 ms 3456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 585 ms 35460 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 Runtime error 1113 ms 62872 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 Runtime error 1086 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 1161 ms 65536 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 65536 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 1088 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 971 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 981 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -