제출 #612141

#제출 시각아이디문제언어결과실행 시간메모리
612141daria기지국 (IOI20_stations)C++14
0 / 100
990 ms708 KiB
#include"bits/stdc++.h" #include "stations.h" #include <vector> using namespace std; const int N = 1000; const int INF = 5000; int T; vector<int> adj[N], lb_a(N), lb_c(N); vector<bool> vis(N); void dfs(int s, bool b){ //b = 0 apertura, b = 1 chiusura if(vis[s]) return; vis[s] = 1; if(!b) lb_a[s] = T++; for(int u : adj[s]) dfs(u, 1-b); if(b) lb_c[s] = T++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for(int i=0; i<n; ++i) adj[i].clear(); lb_a.resize(n); lb_c.resize(n); fill(lb_a.begin(), lb_a.end(), INF); fill(lb_c.begin(), lb_c.end(), INF); fill(vis.begin(), vis.end(), 0); T = 0; for(int i=0; i<n-1; ++i){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0, 0); vector<int> lb(n); map<int, int> mp_a, mp_c; for(int i=0; i<n; ++i) mp_a[lb_a[i]] = i; sort(lb_a.begin(), lb_a.end()); for(int i=0; i<n; ++i){ if(mp_a[i] == INF) break; int j = mp_a[i]; lb[j] = i; } for(int i=0; i<n; ++i) mp_c[lb_c[i]] = i; sort(lb_c.begin(), lb_c.end()); for(int i=0; i<n; ++i){ if(mp_c[i] == INF) break; int j = mp_c[i]; lb[j] = i+N; } //for(int i=0; i<n; ++i) cout << i << " " << lb[i] << endl; return lb; } int find_next_station(int s, int t, vector<int> c) { int par=-1; if(s < N){ //s apertura // le altre sono tutte chiusure par = 0; for(int u : c) par = max(par, u); if(t>=N) t-=N; if(t < s) return par; t+=N; for(int i=0; i<c.size(); ++i) if(c[i] >= t) return c[i]; } else{ // s chiusura // le altre sono tutte aperture par = 400001; for(int u : c) par = min(par, u); if(t<N) t+=N; if(t > s) return par; t-=N; for(int i=c.size()-1; i>=0; --i) if(c[i] <= t) return c[i]; } return par; }

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

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