제출 #14817

#제출 시각아이디문제언어결과실행 시간메모리
14817eaststar어르신 집배원 (BOI14_postmen)C++98
100 / 100
437 ms19560 KiB
#include <stdio.h> int s[500010],e[500010],cnt[500010],a[1000010],visit[500010],chk[500010],p[500010]; void ans(int k){ int t,l; for(;;k=l){ int&n=cnt[k]; for(;(s[a[n]]==k||e[a[n]]==k)&&chk[a[n]];++n); if(s[a[n]]!=k&&e[a[n]]!=k)return; visit[k]=chk[a[n]]=1; l=s[a[n]]==k? e[a[n]]:s[a[n]]; if(visit[l]){ t=k; for(;t!=l;t=p[t]){ visit[t]=0; printf("%d ",t); } printf("%d\n",t); } else p[l]=k; } } int main(){ int i,n,m; scanf("%d%d",&n,&m); for(i=1;i<=m;++i){ scanf("%d%d",s+i,e+i); ++cnt[s[i]],++cnt[e[i]]; } for(i=1;i<=n;++i)cnt[i]+=cnt[i-1]; for(i=1;i<=m;++i)a[--cnt[s[i]]]=a[--cnt[e[i]]]=i; for(i=1;i<=n;++i)ans(i); return 0; }

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

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