QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#470408#995. 桥HHH666#WA 29ms20920kbC++142.2kb2024-07-10 12:57:462024-07-10 12:57:46

Judging History

你现在查看的是最新测评结果

  • [2024-07-10 12:57:46]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:20920kb
  • [2024-07-10 12:57:46]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define i1 __int128
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define all(v) v.begin(), v.end()

using namespace std;

template<typename types>
void read(types &x) {
    x = 0; char c = getchar(); int f = 1;
    while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); }
    while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
    x *= f; return;
}
void read() {}
template<typename types, typename... Args>
void read(types &x, Args&... args) {
    read(x), read(args...);
    return;
}
template<typename types>
void write(types x) {
    if (x < 0) putchar('-'), x = -x;
    types k = x / 10;
    if (k) write(k);
    putchar(x - k * 10 + '0');
    return;
}
void print() { puts(""); }
template<typename types, typename... Args>
void print(types x, Args... args) {
    write(x), putchar(' '), print(args...);
    return;
}

const int MAXN = 1e5 + 10;
const int MAXM = 1e6 + 10;

int n, m;
struct Edge {
    int x, y;
} e[MAXM];
int head[MAXN], to[MAXM], w[MAXM], nxt[MAXM], idx = 1;
int dfn[MAXN], low[MAXN], timecnt;
vector<int> v;

void addedge(int x, int y, int z) {
    nxt[++idx] = head[x];
    to[idx] = y;
    w[idx] = z;
    head[x] = idx;
    return;
}
void dfs(int x, int from) {
    dfn[x] = low[x] = ++timecnt;
    for (int i = head[x]; i; i = nxt[i]) {
        if (i == (from ^ 1)) continue;
        int y = to[i];
        if (!dfn[y]) {
            dfs(y, i);
            low[x] = min(low[y], low[y]);
            if (low[y] > dfn[x]) v.eb(w[i]);
        }
        else low[x] = min(low[x], dfn[y]);
    }
    return;
}

int main() {
    ios:: sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    read(n, m);
    for (int i = 1; i <= m; ++i) {
        read(e[i].x, e[i].y);
        addedge(e[i].x, e[i].y, i), addedge(e[i].y, e[i].x, i);
    }
    for (int i = 1; i <= n; ++i)
        if (!dfn[i]) dfs(i, 0);
    sort(all(v)), v.erase(unique(all(v)), v.end());
    for (int i : v) print(e[i].x, e[i].y);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 29ms
memory: 20920kb

input:

24942 387166
12556 21443
22404 16376
11073 24296
1535 11968
23745 2818
5073 12731
22550 14761
24118 12008
22695 18979
15118 13639
2080 8721
692 22578
22581 15267
9278 4127
7457 21674
17693 23448
10949 23429
9700 6009
14140 5064
7742 15164
17336 1662
18903 9760
17645 19575
6540 11942
11 4937
15282 10...

output:


result:

ok 0 lines

Test #2:

score: 0
Accepted
time: 7ms
memory: 18804kb

input:

10599 87159
4698 4000
60 4705
1476 5947
7273 1716
8004 3018
10094 1717
3092 3493
2613 9681
5427 3723
2510 6343
10113 6322
9257 634
4996 10197
9918 5582
6348 9561
10536 9777
8133 540
1917 7838
6666 2220
7951 815
2873 977
9397 4991
3529 1395
1426 3874
6379 9098
9504 3437
9076 9134
4321 3879
10252 9390...

output:


result:

ok 0 lines

Test #3:

score: -100
Wrong Answer
time: 11ms
memory: 13896kb

input:

43236 126833
40500 20695
21481 27642
28098 41772
412 7750
5862 39561
21777 22303
7868 21217
31658 34299
18532 10934
21931 31023
42926 15624
40332 18017
12484 8663
21927 7910
12504 17943
4379 10252
3523 21794
18641 1965
18633 25061
14639 10800
35958 1441
35044 20249
31491 38161
5749 4468
13403 8413
3...

output:

1349 20915 
15717 34270 
38008 17235 
41266 10868 
19902 3480 
40329 42530 
19516 26641 
43027 24643 
8269 35690 
2098 41076 
6838 38205 
33280 34270 
29027 35410 
20866 26447 
35052 27397 
33860 1309 
35388 534 
25757 13594 
23417 10429 
30628 31979 
38444 33887 
39751 20313 
28554 31809 
39630 346...

result:

wrong answer 2nd lines differ - expected: '38008 17235', found: '15717 34270 '