Submission #427306

#TimeUsernameProblemLanguageResultExecution timeMemory
427306AugustinasJucasStations (IOI20_stations)C++14
0 / 100
3058 ms2097156 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int dydis = 1000; vector<int> gr[dydis]; int enter[dydis]; int leave[dydis]; vector<int> ret (dydis); int dbInd = 0; void dfs(int v, int came){ enter[v] = dbInd++; for(auto x : gr[v]){ if(x == came) continue; dfs(x, v); } leave[v] = dbInd; ret[v] = enter[v] * dydis + leave[v] - 1; //cout << "enter " << v << " - " << enter[v] << ", o leave " << leave[v]-1 << endl; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for(int i = 0; i < n-1; i++){ gr[u[i]].push_back(v[i]); gr[v[i]].push_back(u[i]); } dfs(0, -1); ret.resize(n); return ret; } int find_next_station(int s, int t, vector<int> c) { int enterS = s / 1000; int leaveS = s % 1000; int enterT = t / 1000; int leaveT = t % 1000; // cout << "kitas einant is " << s << " i " << t << " yra:\n"; if(enterS <= enterT && leaveT <= leaveS){ // cout << enterS << " yra " << enterT << " tevas\n"; for(auto x : c){ int e = x / 1000; int l = x % 1000; if(e <= enterT && leaveT <= l && !(e <= enterS && leaveS <= l)){ cout << "ret " << x << endl << endl; return x; } } }else{ // eisiu aukstyn for(auto x : c){ int e = x / 1000; int l = x % 1000; if(e <= enterS && leaveS <= l){ // cout << "ret " << x << endl << endl; return x; } } } return c[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...