Submission #373577

#TimeUsernameProblemLanguageResultExecution timeMemory
373577Jarif_RahmanStations (IOI20_stations)C++17
0 / 100
1061 ms864 KiB
#include "stations.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; vector<vector<int>> v; vector<int> lb; pair<int, int> div(int x){ int y = 1<<10; pair<int, int> r = {x/10, x%10}; return r; } void dfs(int nd, int ss, int a, int b){ lb[nd] = a+b; int sz = v[nd].size(); if(ss == -1) sz++; if(sz > 1){ for(int i = 0; i < 10; i++){ if(!(a&(1<<i))){ a+=1<<i; break; } } } b++; for(int x: v[nd]) if(x != ss) dfs(x, nd, a, b++); } vector<int> label(int n, int k, vector<int> aa, vector<int> bb){ v.assign(n, {}); lb.resize(n); for(int i = 0; i < n-1; i++){ v[aa[i]].pb(bb[i]); v[bb[i]].pb(aa[i]); } dfs(0, -1, 0, 0); return lb; } int find_next_station(int s, int t, vector<int> c){ auto a = div(s), b = div(t); if(a.f != b.f){ if((a.f&b.f) == a.f){ for(int x: c){ auto cc = div(x); if(a.sc > cc.sc) continue; if((cc.f&b.f) == cc.f) return x; } } for(int x: c){ auto cc = div(x); if(a.sc > cc.sc) return x; } } if(a.sc > b.sc){ for(int x: c){ auto cc = div(x); if(a.sc > cc.sc) return x; } } else{ for(int x: c){ auto cc = div(x); if(a.sc > cc.sc) continue; if((cc.f&b.f) == cc.f) return x; } } return 0; }

Compilation message (stderr)

stations.cpp: In function 'std::pair<int, int> div(int)':
stations.cpp:12:9: warning: unused variable 'y' [-Wunused-variable]
   12 |     int y = 1<<10;
      |         ^
#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...