Submission #716490

#TimeUsernameProblemLanguageResultExecution timeMemory
716490myrcellaStations (IOI20_stations)C++17
0 / 100
3030 ms2097152 KiB
//by szh #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl #define pq priority_queue #define inf 0x3f #define rep(i,a,b) for (int i=a;i<(b);i++) #define MP make_pair #define SZ(x) (int(x.size())) #define ll long long #define mod 1000000007 #define ALL(x) x.begin(),x.end() void inc(int &a,int b) {a=(a+b)%mod;} void dec(int &a,int b) {a=(a-b+mod)%mod;} int lowbit(int x) {return x&(-x);} ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;} #include "stations.h" const int maxn = 1010; vector<int> l; vector <int> edge[maxn]; int dfs(int u,int pos,int flag,int lst) { int ret = pos; if (flag==1) l[u] = pos++; for (int v:edge[u]) { if (v==lst) continue; pos += dfs(v,pos,flag^1,u); } if (flag==0) l[u] = pos++; // debug(233),cout<<u<<" "<<l[u]<<endl; return pos-ret; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { l.resize(n); rep(i,0,n-1) { edge[u[i]].pb(v[i]); edge[v[i]].pb(u[i]); } dfs(0,0,0,-1); return l; } int find_next_station(int s, int t, std::vector<int> c) { if (c.back()<s) { rep(i,1,SZ(c)-1) { if (t>=c[i] and t<c[i+1]) return c[i]; } if (t>=c.back() and t<s) return c.back(); return c[0]; } else { assert(c[0]>s); if (t>s and t<=c[0]) return c[0]; rep(i,1,SZ(c)-1) if (t>c[i-1] and t<=c[i]) return c[i]; return c.back(); } }
#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...