# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
931494 | 2024-02-21T23:48:30 Z | beaboss | Stations (IOI20_stations) | C++14 | 3000 ms | 2097152 KB |
#include "bits/stdc++.h" using namespace std; #define s second #define f first #define pb push_back typedef long long ll; typedef pair<int, int> pii; typedef vector<pii> vpii; typedef vector<int> vi; #define FOR(i, a, b) for (int i = (a); i<b; i++) bool ckmin(int& a, int b){ return b < a ? a = b, true : false; } bool ckmax(int& a, int b){ return b > a ? a = b, true : false; } const int N = 1000; vi adj[N]; vi out; int cnt = 0; void dfs(int cur, int d = 0, int p = -1) { if (d % 2 == 0) out[cur] = cnt; cnt++; for (auto val: adj[cur]) if (val != p) dfs(val, d + 1, cur); if (d % 2 == 1) out[cur] = cnt; cnt++; } vi label(int n, int k, vi u, vi v) { FOR(i, 0, u.size()) { adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } out.resize(n); dfs(0); vi other = out; sort(other.begin(), other.end()); FOR(i, 0, out.size()) out[i] = lower_bound(other.begin(), other.end(), out[i]) - other.begin(); return out; } int find_next_station(int s, int t, vi c) { assert(s <= c[0] || s >= c[c.size() - 1]); if (s < c[0]) { // everything is end int p = c[c.size() - 1]; int st = s; // inclusive boud int en = s; // inclusive if (c.size() >= 2) en = max(en, c[c.size() - 2]-1); if (t > en || t < st) return p; return *lower_bound(c.begin(), c.begin() + c.size() - 1, t); } else { int p = c[0]; int st = s-1; // inclusive int en = s-1; // inclusive // cout << st << en << endl; if (c.size() >= 2) st = min(st, c[1]); // cout << st << en << endl; if (t > en || t < st) return p; // cout << t << endl; return *prev(lower_bound(c.begin() + 1, c.end(), t), 1); } } // int main() { // ios::sync_with_stdio(false); // cin.tie(nullptr); // // vi res = label(5, 10, {0, 1, 1, 2}, {1, 2, 3, 4}); // // for (auto val: res) cout << val << endl; // cout << find_next_station(2, 0, {4, 6, 8}) << endl; // }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2066 ms | 2097152 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3019 ms | 540 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1332 ms | 2097152 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 492 ms | 940 KB | Output is correct |
2 | Runtime error | 1091 ms | 2097152 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1707 ms | 2097152 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |