Submission #1192927

#TimeUsernameProblemLanguageResultExecution timeMemory
1192927h1440Stations (IOI20_stations)C++20
0 / 100
0 ms416 KiB
#include "stations.h" #include <bits/stdc++.h> #define fore(i,a,b) for(lli i = (a), abcdxd = (b); i < abcdxd; i++) #define sz(s) (int((s).size())) #define all(v) (v).begin(), (v).end() #define pb push_back using namespace std; typedef int lli; typedef vector<lli> vi; // const lli N = 1e3 + 5; vector<vi> adj; vi labels; lli tim; void dfs(lli u, lli p, lli w){ if (w == 0) labels[u] = tim++; for(auto & i : adj[u]) if (i != p) dfs(i, u, 1-w); if (w == 1) labels[u] = tim++; // cout << u << ": " << tim << endl; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { labels.resize(n+5); adj.resize(n+5, {}); fore(i,0,n-1){ lli a = u[i], b = v[i]; adj[a].pb(b); adj[b].pb(a); } tim = 0; dfs(1, -1, 0); return labels; } int find_next_station(int s, int t, std::vector<int> c) { if (s < c[0]){ c.pb(s); sort(all(c)); fore(i,0,sz(c)-2) if (c[i] < t and t <= c[i+1]) return c[i+1]; return c[sz(c)-1]; } else{ c.pb(s); sort(all(c)); fore(i,1,sz(c)-1) if (c[i] <= t and t < c[i+1]) return c[i]; return c[0]; } return 0; }
#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...