답안 #585640

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
585640 2022-06-29T07:03:00 Z 1zaid1 Pipes (CEOI15_pipes) C++14
0 / 100
243 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int M = 1e5+1;
#define int short int
vector<int> node[M];
int a[M], d[M], tt = 1;
bitset<100005> vis;
vector<pair<int, int>> ans;

void dfs(int s, int p = 1) {
    a[s] = tt++;
    vis[s] = true;
    for (int i:node[s]) {
        if (!vis[i]) {
            dfs(i, s);
            if (a[i] > a[s]) ans.push_back({s, i});
        }
    }

    for (int i:node[s]) if (i != p) a[s] = min(a[s], a[i]);
    d[s] = tt++;
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    
    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= m; i++) {
        int a, b;
        cin >> a >> b;

        node[a].push_back(b);
        node[b].push_back(a);
    }

    for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i); vis = 0;
    for (auto [a, b]:ans) cout << a << ' ' << b << endl;

    return 0;
}
/*
10 11
1 7
1 8
1 6
2 8
6 7
5 8
2 5
2 3
2 4
3 4
10 9

*/

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:39:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   39 |     for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i); vis = 0;
      |     ^~~
pipes.cpp:39:55: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   39 |     for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i); vis = 0;
      |                                                       ^~~
pipes.cpp:40:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   40 |     for (auto [a, b]:ans) cout << a << ' ' << b << endl;
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Incorrect 2 ms 2644 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3284 KB Output is correct
2 Incorrect 4 ms 2900 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 228 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 243 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 225 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 5460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 5572 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 5588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 5588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 5496 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -