QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#384651#4498. Planar GraphTobo#Compile Error//C++202.1kb2024-04-10 08:39:132024-04-10 08:39:13

Judging History

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

  • [2024-04-10 08:39:13]
  • 评测
  • [2024-04-10 08:39:13]
  • 提交

answer

a#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;
        vector<pair<int, int>> tmp;
        auto add = [&](int x, int y)
        { tmp.push_back({x, y}); };
        auto del = [&]()
        { tmp.pop_back(); };
        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])
                {
                    int mi = v;
                    if (!tmp.empty())
                    {
                        auto it = prev(tmp.end());
                        while (it->second != i)
                        {
                            mi = min(mi, it->first);
                            if (it != tmp.begin())
                                it--;
                            else
                                break;
                        }
                    }
                    ans.push_back(v);
                }
                else
                {
                    add(v, cur);
                    dfs(dfs, i, v);
                    del();
                }
            }
        };
        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';
    }
}

Details

answer.code:1:2: error: stray ‘#’ in program
    1 | a#include <bits/stdc++.h>
      |  ^
answer.code:1:1: error: ‘a’ does not name a type
    1 | a#include <bits/stdc++.h>
      | ^
answer.code: In function ‘int main()’:
answer.code:6:5: error: ‘ios_base’ has not been declared
    6 |     ios_base::sync_with_stdio(false);
      |     ^~~~~~~~
answer.code:7:5: error: ‘cin’ was not declared in this scope
    7 |     cin.tie(nullptr);
      |     ^~~
answer.code:15:23: error: ‘pair’ was not declared in this scope
   15 |         vector<vector<pair<int, int>>> adj(n + 1);
      |                       ^~~~
answer.code:15:16: error: ‘vector’ was not declared in this scope
   15 |         vector<vector<pair<int, int>>> adj(n + 1);
      |                ^~~~~~
answer.code:15:28: error: expected primary-expression before ‘int’
   15 |         vector<vector<pair<int, int>>> adj(n + 1);
      |                            ^~~
answer.code:19:13: error: ‘adj’ was not declared in this scope
   19 |             adj[u].push_back({v, i});
      |             ^~~
answer.code:23:18: error: ‘adj’ was not declared in this scope
   23 |             sort(adj[i].begin(), adj[i].end(), [&](auto &e1, auto &e2)
      |                  ^~~
answer.code:23:13: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   23 |             sort(adj[i].begin(), adj[i].end(), [&](auto &e1, auto &e2)
      |             ^~~~
      |             short
answer.code:25:16: error: expected primary-expression before ‘int’
   25 |         vector<int> vis(n + 1);
      |                ^~~
answer.code:26:16: error: expected primary-expression before ‘int’
   26 |         vector<int> ans;
      |                ^~~
answer.code:27:21: error: expected primary-expression before ‘int’
   27 |         vector<pair<int, int>> tmp;
      |                     ^~~
answer.code: In lambda function:
answer.code:29:11: error: ‘tmp’ was not declared in this scope
   29 |         { tmp.push_back({x, y}); };
      |           ^~~
answer.code: In lambda function:
answer.code:31:11: error: ‘tmp’ was not declared in this scope
   31 |         { tmp.pop_back(); };
      |           ^~~
answer.code: In lambda function:
answer.code:34:13: error: ‘vis’ was not declared in this scope
   34 |             vis[cur] = 1;
      |             ^~~
answer.code:35:32: error: ‘adj’ was not declared in this scope; did you mean ‘add’?
   35 |             for (auto [i, v] : adj[cur])
      |                                ^~~
      |                                add
answer.code:42:26: error: ‘tmp’ was not declared in this scope
   42 |                     if (!tmp.empty())
      |                          ^~~
answer.code:44:35: error: there are no arguments to ‘prev’ that depend on a template parameter, so a declaration of ‘prev’ must be available [-fpermissive]
   44 |                         auto it = prev(tmp.end());
      |                                   ^~~~
answer.code:44:35: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
answer.code:54:21: error: ‘ans’ was not declared in this scope
   54 |                     ans.push_back(v);
      |                     ^~~
answer.code: In function ‘int main()’:
answer.code:65:18: error: ‘vis’ was not declared in this scope
   65 |             if (!vis[i])
      |                  ^~~
answer.code:67:14: error: ‘ans’ was not declared in this scope
   67 |         sort(ans.begin(), ans.end());
      |              ^~~
answer.code:67:9: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   67 |         sort(ans.begin(), ans.end());
      |         ^~~~
      |         short
answer.code:68:19: error: ‘unique’ was not declared in this scope
   68 |         ans.erase(unique(ans.begin(), ans.end()), ans.end());
      |                   ^~~~~~
answer.code:69:9: error: ‘cout’ was not declared in this scope
   69 |         cout << ans.size() << '\n';
      |         ^~~~
answer.code: In instantiation of ‘main()::<lambda(auto:3&, int, int)> [with auto:3 = main()::<lambda(auto:3&, int, int)>]’:
answer.code:66:20:   required from here
answer.code:44:49: error: ‘prev’ was not declared in this scope
   44 |                         auto it = prev(tmp.end());
      |                                                 ^
answer.code:47:37: error: ‘min’ was not declared in this scope; did you mean ‘main’?
   47 |                             mi = min(mi, it->first);
      |                                  ~~~^~~~~~~~~~~~~~~
      |                                  main