제출 #548731

#제출 시각아이디문제언어결과실행 시간메모리
548731Amylopectin어르신 집배원 (BOI14_postmen)C++14
55 / 100
577 ms94488 KiB
#include <iostream> #include <stdio.h> #include <vector> using namespace std; const int mxn = 5e5 + 10; struct we { int to,nnu; }; vector<int> ans[mxn] = {}; vector<struct we> pa[mxn] = {}; int pau[mxn] = {},nu[mxn] = {},ctr = -1,ncy = 0; int re(int cn,int be) { int i,j,fn,cnu; nu[cn] = 1; for(i=0; i<pa[cn].size(); i++) { fn = pa[cn][i].to; cnu = pa[cn][i].nnu; if(fn == be || pau[cnu] == 1) continue; if(nu[fn] == 1) { ctr = fn; ans[ncy].push_back(cn); nu[cn] = 0; pau[cnu] = 1; return 0; } re(fn,cn); if(ctr != -1) { ans[ncy].push_back(cn); pau[cnu] = 1; if(cn != ctr) { nu[cn] = 0; return 0; } ncy ++; ctr = -1; } } nu[cn] = 0; return 0; } int main() { int i,j,n,m,cn,cm,fn,fm; scanf("%d %d",&n,&m); for(i=0; i<m; i++) { scanf("%d %d",&cn,&cm); pa[cn].push_back({cm,i}); pa[cm].push_back({cn,i}); } for(i=1; i<=n; i++) { re(i,-1); } for(i=0; i<ncy; i++) { for(j=0; j<ans[i].size(); j++) { printf("%d ",ans[i][j]); } printf("\n"); } return 0; }

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

postmen.cpp: In function 'int re(int, int)':
postmen.cpp:18:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<we>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(i=0; i<pa[cn].size(); i++)
      |              ~^~~~~~~~~~~~~~
postmen.cpp:16:11: warning: unused variable 'j' [-Wunused-variable]
   16 |     int i,j,fn,cnu;
      |           ^
postmen.cpp: In function 'int main()':
postmen.cpp:65:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for(j=0; j<ans[i].size(); j++)
      |                  ~^~~~~~~~~~~~~~
postmen.cpp:51:23: warning: unused variable 'fn' [-Wunused-variable]
   51 |     int i,j,n,m,cn,cm,fn,fm;
      |                       ^~
postmen.cpp:51:26: warning: unused variable 'fm' [-Wunused-variable]
   51 |     int i,j,n,m,cn,cm,fn,fm;
      |                          ^~
postmen.cpp:52:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
postmen.cpp:55:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         scanf("%d %d",&cn,&cm);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...