Submission #835809

#TimeUsernameProblemLanguageResultExecution timeMemory
835809JustAmethystStations (IOI20_stations)C++17
0 / 100
25 ms704 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int N = 1000; vector<int> edges[N]; vector<int> tin(N), tout(N); int t1, t2; void dfs(int x, int p) { tin[x] = t1; ++t1; for (auto y : edges[x]) { if (y != p) { dfs(y, x); } } tout[x] = t2; ++t2; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> labels(n); t1 = 0, t2 = 0; for (int i = 0; i < n; i++) { edges[i].clear(); } for (int i = 0; i < n-1; ++i) { edges[u[i]].push_back(v[i]); edges[v[i]].push_back(u[i]); } dfs(0, -1); for (int i = 0; i < n; ++i) { labels[i] = tin[i]*1000 + tout[i]; } return labels; } int find_next_station(int s, int e, vector<int> c) { int sin = s/1000, sout = s % 1000; int ein = e/1000, eout = e % 1000; cout << sin << " " << sout << " " << ein << "\n"; if (ein < sin) { for (int x : c) { if ((x/1000) <= sin) { return x; } } } for (int x : c) { if ((x/1000) <= ein && (x%1000) >= eout) { return x; } } return -1; } // int main() { // vector<int> labels = label(5, 10, {0, 1, 1, 2}, {1, 2, 3, 4}); // for (auto x : labels) { // cout << x << " "; // cout << "\n"; // } // cout << "\n"; // cout << find_next_station(2001, 3000, {3000, 1003}) << "\n"; // }
#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...