제출 #565129

#제출 시각아이디문제언어결과실행 시간메모리
565129luka1234기지국 (IOI20_stations)C++14
0 / 100
3057 ms2097152 KiB
#include "stations.h" #include<bits/stdc++.h> #include <vector> using namespace std; vector<int> g[1001]; int tin=0; int lab[1001]; map<int,int> mp; void dfs(int v,int e,bool b){ tin++; if(b==0) lab[v]=tin; for(int i:g[v]){ if(i!=e){ dfs(i,v,!b); } } tin++; if(b==1) lab[v]=tin; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { std::vector<int> labels(n); vector<int> vec; for(int i=0;i<n;i++) g[i].clear(); for(int i=0;i<n;i++){ g[v[i]].push_back(u[i]); g[u[i]].push_back(v[i]); } dfs(0,-1,0); for(int k=0;k<n;k++){ vec.push_back(lab[k]); } sort(vec.begin(),vec.end()); for(int k=0;k<n;k++){ mp[vec[k]]=k; } for(int k=0;k<n;k++){ lab[k]=mp[lab[k]]; labels[k]=lab[k]; } return labels; } int find_next_station(int s, int t, std::vector<int> c){ sort(c.begin(),c.end()); int sz=c.size(); if(sz==1) return c[0]; if(s>c[0]){ int mn=c[1]; int mx=s; if(!(t>=mn&&t<=mx)) return c[0]; else{ for(int k=sz-1;k>0;k--){ if(t>=c[k]&&t<=mx) return c[k]; } } } else{ int mn=s; int mx=c[sz-2]; if(!(t>=mn&&t<=mx)) return c[sz-1]; else{ for(int k=0;k<sz-1;k++){ if(t>=s&&t<=c[k]) return c[k]; } } } }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
   75 | }
      | ^
#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...