# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
956836 | 2024-04-02T14:22:29 Z | 12345678 | Stations (IOI20_stations) | C++17 | 2 ms | 856 KB |
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int nx=1e3+5; int in[nx], out[nx], lvl[nx], cnt, pa, t1; vector<int> res, d[nx]; vector<pair<int, int>> mp[nx]; void dfs(int u, int p) { in[u]=++cnt; lvl[u]=lvl[p]+1; for (auto v:d[u]) if (v!=p) dfs(v, u); out[u]=++cnt; if (lvl[u]%2) mp[in[u]].push_back({u, 0}); else mp[out[u]].push_back({u, 1}); } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { cnt=-1; t1=0; for (int i=0; i<n; i++) d[i].clear(); res.resize(n); for (int i=0; i<n-1; i++) d[u[i]].push_back(v[i]), d[v[i]].push_back(u[i]); lvl[0]=0; dfs(0, 0); for (int i=0; i<1000; i++) { if (mp[i].size()>2) cout<<1/0; if (!mp[i].empty()) { for (auto [x, y]:mp[i]) res[x]=t1+y*1000; t1++; } } return res; } int find_next_station(int s, int t, std::vector<int> c) { if (c.size()==1) return c[0]; if (t>=1000) t-=1000; if (s<1000) { for (auto &x:c) x-=1000; if (s==0) for (auto x:c) if (t<=x) return x+1000; pa=c.back(); //cout<<"here "<<s<<' '<<pa<<' '<<t<<'\n'; for (int i=0; i<c.size()-1; i++) if (s<=t&&t<=c[i]) return c[i]+1000; return pa+1000; } else { s-=1000; pa=c.front(); for (int i=c.size()-1; i>0; i--) if (c[i]<=t&&t<=s) return c[i]; return pa; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 856 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 824 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 856 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 500 KB | Execution killed with signal 4 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 756 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |