제출 #1046694

#제출 시각아이디문제언어결과실행 시간메모리
1046694MarwenElarbi기지국 (IOI20_stations)C++17
0 / 100
3061 ms2097152 KiB
#include <bits/stdc++.h> using namespace std; #include "stations.h" #define pb push_back const int nax=10005; vector<int> adj[nax]; int tin[nax]; int tout[nax]; vector<int> ans(nax); int timer=-1; void compute(int x,int p){ tin[x]=++timer; for(auto u:adj[x]){ if(u==p) continue; compute(u,x); } tout[x]=timer; return; } void dfs1(int x,int p,int dep,int cnt){ if(dep==0){ ans[x]=tin[x]-cnt; }else cnt++; for(auto u:adj[x]){ if(u==p) continue; dfs1(u,x,dep^1,cnt); } return; } void dfs2(int x,int p,int dep,int cnt){ if(dep==1){ ans[x]=tout[x]-cnt; cnt++; } vector<int> cur; for(auto u:adj[x]){ cur.pb(u); } reverse(cur.begin(),cur.end()); for(auto u:cur){ if(u==p) continue; dfs2(u,x,dep^1,cnt); } return; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { ans.resize(n); for (int i = 0; i < n-1; i++) { int x=u[i]; int y=v[i]; adj[x].pb(y); adj[y].pb(x); } compute(0,-1); dfs1(0,-1,0,0); dfs2(0,-1,0,0); return ans; } int find_next_station(int s, int t, std::vector<int> c) { sort(c.begin(),c.end()); int lst; if(s>c.back()){ lst=c.back(); if(t>s) return c[0]; for (int i = c.size()-1; i >= 0; --i) { lst=c[i]; if(c[i]<=t) break; } }else{ lst=c[0]; if(t<s) return c.back(); for (int i = 0; i < c.size(); ++i) { lst=c[i]; if(c[i]>=t) break; } } return lst; }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:74:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |         for (int i = 0; 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...