제출 #115962

#제출 시각아이디문제언어결과실행 시간메모리
115962Mahdi_Jfri어르신 집배원 (BOI14_postmen)C++14
55 / 100
627 ms58368 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int maxn = 5e5 + 20; vector<int> adj[maxn] , path; int from[maxn] , to[maxn]; bool visited[maxn]; void dfs(int v) { while(!adj[v].empty()) { int e = adj[v].back() , u = from[e] ^ to[e] ^ v; adj[v].pop_back(); if(visited[e]) continue; visited[e] = 1; dfs(u); } path.pb(v); } int main() { int n , m; scanf("%d%d", &n, &m); for(int i = 0; i < m; i++) { int a , b; scanf("%d%d", &a, &b); a-- , b--; adj[a].pb(i); adj[b].pb(i); from[i] = a , to[i] = b; } dfs(0); vector<int> tmp; memset(visited , 0 , sizeof visited); for(auto v : path) { if(visited[v]) { while(tmp.back() != v) { printf("%d ", tmp.back() + 1); visited[tmp.back()] = 0; tmp.pop_back(); } tmp.pop_back(); printf("%d\n", v + 1); } tmp.pb(v); visited[v] = 1; } }

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

postmen.cpp: In function 'int main()':
postmen.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...