Submission #635913

#TimeUsernameProblemLanguageResultExecution timeMemory
635913AA_SurelySenior Postmen (BOI14_postmen)C++17
0 / 100
13 ms23764 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define FOR(i, x, n) for(int i = x; i < n; i++) #define F0R(i, n) FOR(i, 0, n) #define ROF(i, x, n) for(int i = n - 1; i >= x; i--) #define R0F(i, n) ROF(i, 0, n) #define WTF cout << "WTF" << endl #define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define F first #define S second #define PB push_back #define EP emplace_back #define ALL(x) x.begin(), x.end() #define RALL(x) x.rbegin(), x.rend() using namespace std; typedef long long LL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef vector<int> VI; typedef vector<LL> VLL; typedef vector<PII> VPII; typedef vector<PLL> VPLL; const int N = 5e5 + 7; int n, m, ptr; bool vis[N], seen[N]; int cnt[N]; VPII adj[N]; VI ans[N]; struct Tour { bool vis[N]; VI ord; void add(int x) { if (vis[x]) { int now = ord.back(); while(now != x) { ans[ptr].PB(now); vis[now] = 0; ord.pop_back(); now = ord.back(); } ans[ptr].PB(now); vis[now] = 0; ord.pop_back(); ptr++; } vis[x] = 1; ord.PB(x); return; } } etds; void init() { cin >> n >> m; F0R(i, m) { int u, v; cin >> u >> v; adj[--u].PB({--v, i}); adj[v].PB({u, i}); } return; } void dfs(int now) { vis[now] = 1; cout << "now on : " << now + 1 << endl; while(cnt[now] < adj[now].size()) { cnt[now]++; if (!seen[adj[now][ cnt[now] - 1 ].S]) { seen[adj[now][ cnt[now] - 1 ].S] = 1; dfs(adj[now][ cnt[now] - 1 ].F); } } etds.add(now); return; } int main() { IOS; init(); F0R(i, n) if (!vis[i]) dfs(i); F0R(i, ptr) { for(int on : ans[i]) cout << on + 1 << ' '; cout << endl; } return 0; }

Compilation message (stderr)

postmen.cpp: In function 'void dfs(int)':
postmen.cpp:83:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     while(cnt[now] < adj[now].size()) {
      |           ~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...