# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
422613 | 2021-06-10T09:10:43 Z | TLP39 | Stations (IOI20_stations) | C++14 | 3000 ms | 2097156 KB |
#include "stations.h" #include <vector> #include <bits/stdc++.h> using namespace std; int n; vector<int> adj[1003]; int par[1003]={}; int si[1003]={}; int lab[1003]; void dfs(int v) { si[v]=1; for(int i=0;i<adj[v].size();i++) { if(adj[v][i]==par[v]) continue; par[adj[v][i]]=v; dfs(adj[v][i]); si[v]+=si[adj[v][i]]; } } void getlabel(int v,int st,int ed) { lab[v]=st; if(st==ed) return; int x=st,y; if(st<ed) { for(int i=0;i<adj[v].size();i++) { if(adj[v][i]==par[v]) continue; y=x+1; x+=si[adj[v][i]]; getlabel(adj[v][i],x,y); } return; } for(int i=0;i<adj[v].size();i++) { if(adj[v][i]==par[v]) continue; y=x-1; x-=si[adj[v][i]]; getlabel(adj[v][i],x,y); } return; } std::vector<int> label(int N, int k, std::vector<int> u, std::vector<int> v) { n=N; std::vector<int> labels(N); par[0]=-1; for(int i=0;i<n-1;i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0); getlabel(0,0,n-1); for(int i=0;i<n;i++) labels[i]=lab[i]; return labels; } int find_next_station(int s, int t, std::vector<int> c) { if(c.size()==1) return c[0]; if(s==0) { for(int i=0;i<c.size();i++) { if(c[i]>=t) return c[i]; } } if(c[0]<s) { if(t>s || t<c[1]) return c[0]; for(int i=c.size()-1;i>0;i--) { if(c[i]<=t) return c[i]; } } int ss=c.size()-1; if(t<s || t>c[ss-1]) return c[ss]; for(int i=0;i<ss;i++) { if(t<=c[i]) return c[i]; } return -1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2492 ms | 2097156 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3041 ms | 420 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1672 ms | 2097156 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 922 ms | 552 KB | Output is correct |
2 | Runtime error | 1320 ms | 2097156 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2857 ms | 2097156 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |