제출 #98423

#제출 시각아이디문제언어결과실행 시간메모리
98423Kastanda어르신 집배원 (BOI14_postmen)C++11
55 / 100
698 ms62464 KiB
#include<bits/stdc++.h> using namespace std; const int N = 500005; int n, m, cyc, from[N], to[N], M[N], S[N]; int cnt = 0; vector < int > Adj[N]; void DFS(int v) { cnt ++; assert(cnt <= m + n); S[v] = 1; while (Adj[v].size()) { int id = Adj[v].back(); Adj[v].pop_back(); if (M[id]) continue; M[id] = 1; int u = from[id] ^ to[id] ^ v; if (S[u]) { cyc = u; S[v] = 0; cout << v; return ; } DFS(u); if (cyc) cout << ' ' << v; if (cyc != v) { S[v] = 0; return ; } else cyc = 0, cout << '\n'; } S[v] = 0; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { scanf("%d%d", &from[i], &to[i]); Adj[from[i]].push_back(i); Adj[to[i]].push_back(i); } for (int i = 1; i <= n; i++) if (Adj[i].size()) DFS(i); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

postmen.cpp: In function 'int main()':
postmen.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &from[i], &to[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...