Submission #683581

#TimeUsernameProblemLanguageResultExecution timeMemory
683581whqkrtk04Stations (IOI20_stations)C++17
0 / 100
4 ms1024 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<int, pii> piii; typedef pair<ll, ll> pll; typedef pair<ll, pll> plll; #define fi first #define se second const int INF = 1e9+1; const int P = 1000000007; const ll LLINF = (ll)1e18+1; template <typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { os << p.fi << " " << p.se; return os; } template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { for(auto i : v) os << i << " "; os << "\n"; return os; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define rnd(x, y) uniform_int_distribution<int>(x, y)(rng) const int MAX = 1000; void dfs(int x, int &cnt, vector<vector<int>> &E, vector<int> &I, vector<int> &O, vector<bool> &vis) { if(vis[x]) return; vis[x] = true; I[x] = cnt++; for(auto i : E[x]) dfs(i, cnt, E, I, O, vis); O[x] = cnt; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { int cnt = 0; vector<bool> vis(n, false); vector<int> I(n), O(n); vector<vector<int>> E(n); for(int i = 0; i+1 < n; i++) { E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]); } dfs(0, cnt, E, I, O, vis); vector<int> ret(n); for(int i = 0; i < n; i++) ret[i] = I[i]*MAX+(O[i]-I[i]); return ret; } pii parse(int x) { return {x/MAX, x/MAX+x%MAX}; } int find_next_station(int s, int t, vector<int> c) { pii S = parse(s), T = parse(t); if(T.fi < S.fi || T.fi >= S.se) return c[0]; for(int i = 1; i < c.size(); i++) { pii tmp = parse(c[i]); if(tmp.fi <= T.fi && T.fi < tmp.se) return c[i]; } assert(0); return 0; }

Compilation message (stderr)

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