답안 #99693

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

const int N = 1e5 + 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 8 ms 8192 KB Output is correct
2 Correct 9 ms 8192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 9088 KB Output is correct
2 Correct 21 ms 8912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 971 ms 41072 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 1917 ms 63360 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 1591 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1719 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1682 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1637 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1673 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1694 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -