답안 #99694

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99694 2019-03-06T07:10:22 Z adlet Pipes (CEOI15_pipes) C++17
20 / 100
2001 ms 56276 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e4 + 5;

int n, m, cnt, timer, fup[N], used[N], tin[N];

vector < int > g[N];

vector < pair < int, int > > ans;

unordered_map < int, int > mp[N];

inline void dfs(int v, int p = -1) {
    used[v] = 1;
    tin[v] = ++timer;
    fup[v] = timer;
    for (int to : g[v]) {
        if (to == p)
            continue;
        if (used[to])
            fup[v] = min(fup[v], tin[to]);
        else {
            dfs(to, v);
            fup[v] = min(fup[v], fup[to]);
            if (fup[to] > tin[v] && (mp[v][to] == 1 || mp[to][v] == 1))
                ans.push_back({v, to});
        }
    }
}

int main() {
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        int v, u;
        cin >> v >> u;
        g[v].push_back(u);
        g[u].push_back(v);
        mp[v][u]++;
    }
    for (int i = 1; i <= n; ++i) {
        if (!used[i]) {
            dfs(i);
        }
    }
    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i].first << " " << ans[i].second << (i + 1 == ans.size() ? "" : "\n");
    }
}

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:46:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < ans.size(); ++i) {
                     ~~^~~~~~~~~~~~
pipes.cpp:47:64: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         cout << ans[i].first << " " << ans[i].second << (i + 1 == ans.size() ? "" : "\n");
                                                          ~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Correct 2 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2048 KB Output is correct
2 Correct 12 ms 1920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 995 ms 34076 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 2001 ms 56276 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 3 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 2020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2000 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2056 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -