답안 #152693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
152693 2019-09-09T07:44:17 Z toloraia Pipes (CEOI15_pipes) C++14
30 / 100
2380 ms 65540 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
//#pragma comment(linker, "/STACK: 20000000005")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

const int N = 1e5 + 5, M = 6e6 + 5;

int n, m;
int nn, u[N], v[N];

vector < int > g[N];

int T;
int in[N], up[N];

void dfs (int k, int p){
    in[k] = ++T;
    up[k] = in[k];
    int to;
    for (int toto : g[k]){
        to = abs (toto);
        if (to == p)
            continue;
        if (in[to]){
            up[k] = min (up[k], in[to]);
            continue;
        }
        dfs (to, k);
        if (up[to] > in[k] && toto > 0){
            nn++;
            u[nn] = k;
            v[nn] = to;
        }
        up[k] = min (up[k], up[to]);
    }
}

pair < int, int > P[M];

main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        cin >> P[i].F >> P[i].S;
    }
    sort (P + 1, P + m + 1);
    for (int i = 1; i <= m; i++){
        if (P[i] == P[i - 1])
            continue;
        if (P[i + 1] != P[i]){
            g[P[i].F].pb (P[i].S);
            g[P[i].S].pb (P[i].F);
        }
        else {
            g[P[i].F].pb (-P[i].S);
            g[P[i].S].pb (-P[i].F);
        }
    }
    for (int i = 1; i <= n; i++)
        if (in[i] == 0)
            dfs (i, 0);
    for (int i = 1; i <= nn; i++)
        cout << u[i] << " " << v[i] << endl;
    return 0;
}

Compilation message

pipes.cpp:17:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
pipes.cpp:18:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
pipes.cpp:55:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2676 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 3192 KB Output is correct
2 Correct 10 ms 3064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 241 ms 15288 KB Output is correct
2 Correct 228 ms 14712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 401 ms 21380 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 663 ms 35228 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 911 ms 41248 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 1455 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 1760 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 2045 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 2380 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -