제출 #616956

#제출 시각아이디문제언어결과실행 시간메모리
616956chirathnirodha기지국 (IOI20_stations)C++17
0 / 100
1063 ms800 KiB
#include "stations.h" #include<bits/stdc++.h> using namespace std; #define PB push_back #define MP make_pair #define F first #define S second vector<pair<int,int>> lab; int in[1000],out[1000]; vector<int> ed[1000]; int cur; void dfs(int x,int dep){ in[x]=cur;cur++; for(int i=0;i<ed[x].size();i++){ int y=ed[x][i]; if(in[y]!=-1)continue; dfs(y,dep+1); } out[x]=cur;cur++; if(dep%2==0)lab.PB(MP(in[x],x)); else lab.PB(MP(out[x],x)); } vector<int> label(int n, int k, vector<int> u, vector<int> v) { memset(in,-1,sizeof(in)); memset(out,-1,sizeof(out)); lab.clear(); for(int i=0;i<n;i++)ed[i].clear(); for(int i=0;i<n-1;i++){ ed[u[i]].PB(v[i]); ed[v[i]].PB(u[i]); } cur=0; dfs(0,0); sort(lab.begin(),lab.end()); vector<int> labels(n); for(int i=0;i<n;i++){ labels[lab[i].S]=i; } return labels; } int find_next_station(int s, int t, vector<int> c) { sort(c.begin(),c.end()); if(s<c[0]){ for(int i=0;i<c.size()-1;i++){ if(t<c[i])return c[i]; } return c.back(); } else{ for(int i=1;i<c.size();i++){ if(t>c[i])return c[i]; } return c[0]; } }

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

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i=0;i<ed[x].size();i++){
      |              ~^~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:45:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int i=0;i<c.size()-1;i++){
      |               ~^~~~~~~~~~~
stations.cpp:51:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   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...