제출 #614472

#제출 시각아이디문제언어결과실행 시간메모리
614472penguinhacker기지국 (IOI20_stations)C++17
0 / 100
414 ms824 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int mxN=1000; int n, tin[mxN], tout[mxN], t, d[mxN]; vector<int> adj[mxN]; void dfs(int u=0, int p=-1) { tin[u]=t++; for (int v : adj[u]) if (v!=p) { d[v]=d[u]+1; dfs(v, u); } tout[u]=t++; } vector<int> label(int _n, int _k, vector<int> u, vector<int> v) { n=_n; for (int i=0; i<n; ++i) adj[i].clear(); for (int i=0; i<n-1; i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } vector<int> inds(n), labels(n); iota(inds.begin(), inds.end(), 0); sort(inds.begin(), inds.end(), [](int a, int b) { return (d[a]%2?tout[a]:tin[a])<(d[b]%2?tout[b]:tin[b]); }); for (int i=0; i<n; ++i) labels[inds[i]]=i; return labels; } int find_next_station(int s, int t, vector<int> c) { if (c.back()>s) { // s is tin[s] if (!s||s<=t&&t<=c.end()[-2]) { // t is in subtree of s for (int i=0; i+(s>0)<c.size(); ++i) if (t<=c[i]) return c[i]; assert(0); } else return c.back(); } else { if (c[1]<=t&&t<=s) { // again in subtree for (int i=c.size()-1; i; --i) if (t>=c[i]) return c[i]; assert(0); } else return c[0]; } }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:37:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   37 |   if (!s||s<=t&&t<=c.end()[-2]) { // t is in subtree of s
stations.cpp:38:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    for (int i=0; i+(s>0)<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...