# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433090 | 2021-06-18T20:35:01 Z | Enkognit | Stations (IOI20_stations) | C++14 | 5 ms | 920 KB |
#include <bits/stdc++.h> #include "stations.h" #include <vector> #define ll long long #define mp make_pair #define pb push_back #define fi first #define se second using namespace std; vector<ll> c[1005]; ll T; ll in[1005], out[1005], pp[1005]; void dfs(int h,int p=-1) { pp[h]=p; in[h]=++T; for (int i = 0; i < c[h].size(); i++) if (c[h][i]!=p) { dfs(c[h][i], h); } out[h]=++T; } bool is_ancestor(int x,int y) { return in[x]<=in[y] && out[x]>=out[y]; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { std::vector<int> labels(n); T=0; for (int i = 0; i < n; i++) { labels[i] = i; c[i].clear(); } for (int i = 0; i < n-1; i++) { c[u[i]].pb(v[i]); c[v[i]].pb(u[i]); } dfs(0); return labels; } ll TT; bool dfs2(int h,int p=-1) { if (h==TT) return 1; for (int i = 0; i < c[h].size(); i++) if (c[h][i]!=p) { if (dfs2(c[h][i], h)) return 1; } return 0; } int find_next_station(int s, int t, std::vector<int> cc) { //cout << "!\n"; if (!is_ancestor(s, t)) { TT=t; assert(dfs2(pp[s], s)); return pp[s]; } for (int i = 0; i < cc.size(); i++) if (is_ancestor(cc[i], t) && pp[s]!=cc[i]) { TT=t; assert(dfs2(cc[i], s)); return cc[i]; } } /* 1 5 10 0 1 1 2 1 3 2 4 2 2 0 2 1 3 3 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 912 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 780 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 904 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 760 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 920 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |