Submission #311996

#TimeUsernameProblemLanguageResultExecution timeMemory
311996MrGaryStations (IOI20_stations)C++17
0 / 100
1031 ms1264 KiB
/* { ###################### # Author # # Gary # # 2020 # ###################### */ #pragma GCC optimize(2) #include<bits/stdc++.h> #define rb(a,b,c) for(int a=b;a<=c;++a) #define rl(a,b,c) for(int a=b;a>=c;--a) #define LL long long #define IT iterator #define PB push_back #define II(a,b) make_pair(a,b) #define FIR first #define SEC second #define FREO freopen("check.out","w",stdout) #define rep(a,b) for(int a=0;a<b;++a) #define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) #define random(a) rng()%a #define ALL(a) a.begin(),a.end() #define POB pop_back #define ff fflush(stdout) #define fastio ios::sync_with_stdio(false) #define R(a) cin>>a #define R2(a,b) cin>>a>>b #define check_min(a,b) a=min(a,b) #define check_max(a,b) a=max(a,b) //#include "stations.h" using namespace std; const int INF=0x3f3f3f3f; typedef pair<int,int> mp; /*} */ vector<int> g[1001]; int id[1001]; int cnt=0; void run(int now,int pre=0,int depth=1){ if(depth) id[now]=cnt++; for(auto it:g[now]){ if(it!=pre){ run(it,now,depth^1); } } if(!depth) id[now]=cnt++; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { std::vector<int> labels(n); cnt=0; rep(i,n) g[i].clear(); rep(i,n-1) g[u[i]].PB(v[i]),g[v[i]].PB(u[i]); run(0); rep(i,n) labels[i]=id[i]; return labels; } int find_next_station(int s, int t, std::vector<int> c) { sort(ALL(c)); if(s<c[0]){ if(s==0||(c.size()>=2&&t<=c[c.size()-2])){ return *lower_bound(ALL(c),t); } return c.back(); } else{ if(c.size()>=2&&t>=c[1]){ return *(upper_bound(ALL(c),t)-1); } return c[0]; } } //int main(){ // fastio; // // 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...