Submission #980627

# Submission time Handle Problem Language Result Execution time Memory
980627 2024-05-12T09:30:54 Z Zicrus Senior Postmen (BOI14_postmen) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll n, m, u, v;
vector<queue<pair<ll, ll>>> adj;
vector<ll> res;

vector<bool> sus;

void euler(ll s) {
    while (!adj[s].empty()) {
        ll e = adj[s].front().first;
        ll i = adj[s].front().second;
        adj[s].pop();
        if (!sus[i]) { sus[i] = true; euler(e); }
        sus[i] = true;
    }
    res.push_back(s);
}

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

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

Compilation message

postmen.cpp: In function 'int main()':
postmen.cpp:39:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (ll i = 0; i < res.size(); i++) {
      |                    ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Edge does not exist or used 3, 7
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Edge does not exist or used 3, 7
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Edge does not exist or used 3, 7
3 Halted 0 ms 0 KB -