Submission #980755

#TimeUsernameProblemLanguageResultExecution timeMemory
980755ZicrusSenior Postmen (BOI14_postmen)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

int n, m, u, v;
vector<pair<int, int>> adj[500000];
int res[500001];
int resI = 0;

bool sus[500000];

int main() {
    cin >> n >> m;
    vector<int> deg(n);
    int g = 0;
    for (int i = 0; i < m; i++) {
        cin >> u >> v;
        adj[u-1].push_back({v-1, g});
        adj[v-1].push_back({u-1, g++});
    }

    stack<int> stk;
    stk.push(0);
    while (!stk.empty()) {
        start:
        int s = stk.top();
        while (!adj[s].empty()) {
            int e = adj[s].back().first;
            int i = adj[s].back().second;
            adj[s].pop_back();
            if (!sus[i]) { sus[i] = true; stk.push(e); goto start; }
            else sus[i] = true;
        }
        res[resI++] = s;
        stk.pop();
    }

    reverse(res.begin(), res.end());
    vector<int> vst(n, -1);
    vector<int> nxt(n, -1);
    for (int i = 0; i < res.size(); i++) {
        int node = res[i];
        if (vst[node] == -1) {
            vst[node] = i;
            nxt[node] = res[i+1];
        }
        else {
            int nd = res[vst[node]];
            do {
                cout << nd+1 << ' ';
                vst[nd] = -1;
                nd = nxt[nd];
            } while (nd != node);
            cout << '\n';
            nxt[node] = res[i+1];
            vst[node] = i;
        }
    }
}

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:37:17: error: request for member 'begin' in 'res', which is of non-class type 'int [500001]'
   37 |     reverse(res.begin(), res.end());
      |                 ^~~~~
postmen.cpp:37:30: error: request for member 'end' in 'res', which is of non-class type 'int [500001]'
   37 |     reverse(res.begin(), res.end());
      |                              ^~~
postmen.cpp:40:29: error: request for member 'size' in 'res', which is of non-class type 'int [500001]'
   40 |     for (int i = 0; i < res.size(); i++) {
      |                             ^~~~