QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#384642#4498. Planar GraphTobo#WA 675ms17168kbC++201.3kb2024-04-10 08:25:082024-04-10 08:25:09

Judging History

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

  • [2024-04-10 08:25:09]
  • 评测
  • 测评结果:WA
  • 用时:675ms
  • 内存:17168kb
  • [2024-04-10 08:25:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        vector<vector<pair<int, int>>> adj(n + 1);
        for (int i = 1, u, v; i <= m; i++)
        {
            cin >> u >> v;
            adj[u].push_back({v, i});
            adj[v].push_back({u, i});
        }
        for (int i = 1; i <= n; i++)
            sort(adj[i].begin(), adj[i].end(), [&](auto &e1, auto &e2)
                 { return e1.second > e2.second; });
        vector<int> vis(n + 1);
        vector<int> ans;
        auto dfs = [&](auto &dfs, int cur, int id) -> void
        {
            vis[cur] = 1;
            for (auto [i, v] : adj[cur])
            {
                if (v == id)
                    continue;
                if (vis[i])
                    ans.push_back(v);
                else
                    dfs(dfs, i, v);
            }
        };
        for (int i = 1; i <= n; i++)
            if (!vis[i])
                dfs(dfs, i, -1);
        sort(ans.begin(), ans.end());
        ans.erase(unique(ans.begin(), ans.end()), ans.end());
        cout << ans.size() << '\n';
        for (int i : ans)
            cout << i << ' ';
        cout << '\n';
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 675ms
memory: 17168kb

input:

15
5 7
1 1
1 2
1 3
3 4
3 4
2 4
2 5
9 9
1 2
2 3
3 1
4 5
5 6
6 4
7 8
8 9
9 7
100000 0
100000 200000
77128 77528
77919 78319
67747 68147
21468 21468
9500 9500
3099 3099
60221 60222
71712 71713
26587 93317
6972 6972
58270 58271
7190 7190
76105 76106
73929 74329
32751 32751
4 5
35248 35648
4492 96872
160...

output:

3
1 2 4 
3
1 4 7 
0

106620
1 2 3 4 5 6 7 10 11 12 13 14 15 16 19 20 21 22 23 26 27 28 29 30 31 33 34 36 39 40 41 42 43 45 46 47 48 52 53 55 56 57 59 61 62 65 66 68 69 72 73 74 75 77 78 79 80 83 84 85 86 87 88 89 90 91 92 93 94 95 96 98 100 101 103 105 106 107 108 109 110 111 113 114 115 116 117 118...

result:

wrong answer 8th lines differ - expected: '1 2 3 4 5 6 7 8 10 11 12 13 14...990 199991 199992 199999 200000', found: '1 2 3 4 5 6 7 10 11 12 13 14 1...90 199991 199992 199999 200000 '