답안 #1055405

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055405 2024-08-12T18:47:59 Z vjudge1 Pipes (CEOI15_pipes) C++17
10 / 100
804 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3")
#define endl '\n'
#define db double
#define ll __int128
//#define int long long
#define pb push_back
#define fs first
#define sd second
#define Mod long(1e9 + 7)
#define all(x) x.begin(), x.end()
#define unvisited long(-1)
#define Eps double(1e-9)
#define _for(i, n) for(int i = 0; i < (n); i++)
#define dbg(x) cout << #x ": " << x << endl;

const int Max = 1e6 + 7, Inf = 1e16 + 7;

void print(bool x) { cout << (x ? "YES" : "NO") << endl; }

string tostring (__int128 x)
{
    string ans = "";
    while(x > 0)
    {
        ans += (x % 10 + '0');
        x /= 10;
    }
    reverse(all(ans));
    return ans;
}

vector <vector<int>> v; 
vector <int> p; 
int idx = 1;

int dfs(int node, int parent)
{ 
    if(p[node]) return p[node]; 
    p[node] = idx; idx++; 
    int mn = Inf; 
    for(auto& u : v[node]) if(u != parent)
    {
        int t = dfs(u, node); 
        mn = min(mn, t); 
        if(t > p[node]){
            cout << node << " " << u << endl;
        }
    }
    return p[node] = mn; 
}

void solve()
{
    int n, m; cin >> n >> m; 
    v.assign(n+1, vector <int> ()); 
    p.assign(n+1,0 );
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b; 
        v[a].pb(b); v[b].pb(a); 
    }

    for(int i = 1; i <= n; i++) if(!p[i]){
        dfs(i, 0); 
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int Q = 1; //cin >> Q;

    while (Q--)
    {
        solve();
    }

    return 0;
}

Compilation message

pipes.cpp:19:37: warning: overflow in conversion from 'double' to 'int' changes value from '1.0000000000000008e+16' to '2147483647' [-Woverflow]
   19 | const int Max = 1e6 + 7, Inf = 1e16 + 7;
      |                                ~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 860 KB Output is correct
2 Incorrect 3 ms 604 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 8560 KB Output is correct
2 Correct 56 ms 8020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 12164 KB Output is correct
2 Runtime error 123 ms 16468 KB Memory limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 195 ms 23376 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 284 ms 30396 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 431 ms 52304 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 563 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 691 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 804 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -