제출 #321906

#제출 시각아이디문제언어결과실행 시간메모리
321906tigichaStations (IOI20_stations)C++17
100 / 100
1156 ms1292 KiB
#include<bits/stdc++.h> using namespace std; int fix[1005], l; vector<int>vec[1005], labels; void dfs(int x, int y){ fix[x]=1; if(y%2==0){ l++; labels[x]=l; } for(int i=0; i<vec[x].size(); i++) if(fix[vec[x][i]]!=1) dfs(vec[x][i], y+1); if(y%2==1){ l++; labels[x]=l; } } std::vector<int> label(int n, int k, std::vector<int>u, std::vector<int>v){ labels.clear(); for(int i=0; i<n; i++) labels.push_back(-1); l=0; for(int i=0; i<n; i++){ vec[i].clear(); fix[i]=0; } for(int i=0; i<u.size(); i++){ vec[u[i]].push_back(v[i]); vec[v[i]].push_back(u[i]); } dfs(0, 0); return labels; } int find_next_station(int s, int t, std::vector<int>c){ if(s<c[0]){ if(t>s){ for(int i=0; i<c.size()-1; i++) if(t>c[i]) continue; else return c[i]; } return c[c.size()-1]; } else{ if(t<s){ for(int i=c.size()-1; i>0; i--) if(t<c[i]) continue; else return c[i]; } return c[0]; } }

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

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:11:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i=0; i<vec[x].size(); i++)
      |               ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(int i=0; i<u.size(); i++){
      |               ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |    for(int i=0; i<c.size()-1; i++)
      |                 ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...