제출 #926800

#제출 시각아이디문제언어결과실행 시간메모리
926800velislavgarkov기지국 (IOI20_stations)C++14
0 / 100
1 ms544 KiB
#include "stations.h" #include <iostream> #include <algorithm> #include <vector> using namespace std; const int MAXN=1e3+10; struct Number { int x; int ind; bool friend operator < (Number a, Number b) { return a.x<b.x; } }; Number num[MAXN]; vector <int> ver[MAXN]; vector <int> ans; int in[MAXN], out[MAXN], dep[MAXN]; int br; void dfs(int x, int par) { in[x]=br; br++; for (auto i:ver[x]) { if (i==par) continue; dep[i]=dep[x]+1; dfs(i,x); } out[x]=br; br++; if (dep[x]%2==0) num[x].x=in[x]; else num[x].x=out[x]; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for (int i=0;i<n;i++) { if (!ver[i].empty()) ver[i].clear(); num[i].ind=i; } for (int i=0;i<n-1;i++) { ver[u[i]].push_back(v[i]); ver[v[i]].push_back(u[i]); } dep[0]=br=0; dfs(0,-1); sort(num,num+n); ans.resize(n); for (int i=0;i<n;i++) ans[num[i].ind]=i; for (int i=0;i<n;i++) cout << ans[i] << ' '; cout << endl; return ans; } int find_next_station(int s, int t, vector<int> c) { if (s==0) { for (int i=0;i<c.size();i++) { if (c[i]>=t) return c[i]; } return c.back(); } else if (s<c[0]) { //if (t<s) return c.back(); for (int i=0;i<c.size()-1;i++) { if (c[i]>=t) return c[i]; } return c.back(); } else { if (t>s) return c[0]; int res=c[0]; for (int i=1;i<c.size();i++) { if (c[i]<=t) res=c[i]; } return res; } }

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

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