제출 #795885

#제출 시각아이디문제언어결과실행 시간메모리
795885BT21tata기지국 (IOI20_stations)C++17
100 / 100
780 ms848 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; int cur; vector<int> g[1005], labels; void dfs(int v, int p, int x) { if(!x) labels[v]=cur++; for(int u : g[v]) { if(u==p) continue; dfs(u, v, x^1); } if(x) labels[v]=cur++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { labels.resize(n, 0); for(int i=0; i<n; i++) g[i].clear(); cur=0; for(int i=0; i<u.size(); i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } dfs(0, -1, 0); /*for(int u :labels) cout<<u<<' '; cout<<flush;*/ return labels; } int find_next_station(int s, int t, vector<int> c) { sort(c.begin(), c.end()); if(s<c[0]) { int fs=s; for(int i=0; i<c.size()-1; i++) { if(fs<=t and t<=c[i]) return c[i]; fs=c[i]+1; } return c.back(); } else { int last=s; for(int i=c.size()-1; i>0; i--) { if(c[i]<=t and t<=last) return c[i]; last=c[i]-1; } return c[0]; } }

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

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int i=0; i<u.size(); i++)
      |               ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:43:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   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...