제출 #31548

#제출 시각아이디문제언어결과실행 시간메모리
31548ngkan146어르신 집배원 (BOI14_postmen)C++98
100 / 100
487 ms26232 KiB
#include <bits/stdc++.h> using namespace std; int ctrl[500005]; int nxt[1000005], prv[1000005], id[1000005]; int head[500005], en[500005]; bool visited[500005]; int n,m; int euler[1000005], eulersize; int q[1000005], qsize; void dfs(){ q[qsize++] = 1; while(qsize){ int u = q[qsize-1]; bool mjk = 0; for(;ctrl[u];ctrl[u] = nxt[ctrl[u]]){ int v = (u ^ head[id[ctrl[u]]] ^ en[id[ctrl[u]]]); if (visited[id[ctrl[u]]]) continue; mjk = 1; visited[id[ctrl[u]]] = 1; q[qsize++] = v; break; } if(mjk) continue; euler[eulersize++] = u; --qsize; } } int st[1000005], stsize; bool used[1000005]; int main(){ scanf("%d %d",&n,&m); int cnt = 0; for(int i=1;i<=m;++i){ int x,y; scanf("%d %d",&x,&y); if (!ctrl[x]){ ctrl[x] = ++cnt; id[cnt] = i; prv[x] = cnt; } else nxt[prv[x]] = ++cnt, id[cnt] = i, prv[x] = cnt; if (!ctrl[y]){ ctrl[y] = ++cnt; id[cnt] = i; prv[y] = cnt; } else nxt[prv[y]] = ++cnt, id[cnt] = i, prv[y] = cnt; head[i] = x; en[i] = y; } dfs(); for(int i=0;i<eulersize;++i){ if (used[euler[i]]){ while(st[stsize-1] != euler[i]){ printf("%d ",st[stsize-1]); used[st[stsize-1]] = 0; --stsize; }; printf("%d\n",euler[i]); } else{ st[stsize++] = euler[i]; used[euler[i]] = 1; } } }

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

postmen.cpp: In function 'int main()':
postmen.cpp:33: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:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&x,&y);
         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...