# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
309800 | 2020-10-04T14:47:14 Z | tjdgus4384 | Stations (IOI20_stations) | C++14 | 974 ms | 784 KB |
#include<bits/stdc++.h> #include "stations.h" using namespace std; bool visited[1001]; vector<int> path[1001]; int num1[1001], num2[1001]; int dfs1(int x, int cnt){ num1[x] = cnt; cnt++; for(int i = 0;i < path[x].size();i++){ if(visited[path[x][i]]) continue; visited[path[x][i]] = true; cnt = dfs1(path[x][i], cnt); } return cnt; } int dfs2(int x){ int ret = num1[x]; for(int i = 0;i < path[x].size();i++){ if(visited[path[x][i]]) continue; visited[path[x][i]] = true; ret = dfs2(path[x][i]); } return num2[x] = ret; } vector<int> label(int n, int k, vector<int> u, vector<int> v){ for(int i = 0;i < n;i++){ path[u[i]].push_back(v[i]); path[v[i]].push_back(u[i]); } visited[0] = true; dfs1(0, 0); for(int i = 0;i < n;i++) visited[i] = false; visited[0] = true; dfs2(0); vector<int> ret; for(int i = 0;i < n;i++){ ret.push_back(num1[i]*1000+num2[i]); } return ret; } int find_next_station(int s, int t, vector<int> c){ int num2s = s%1000, num2t = t%1000; int num1s = (s-num2s)/1000, num1t = (t-num2t)/1000; int reti; for(int i = 0;i < c.size();i++){ num2[i] = c[i]%1000; num1[i] = (c[i]-num2[i])/1000; if(num1[i] < num1s) reti = i; } if(num1t > num1s && num1t <= num2s){ int s = 1, e = c.size() - 1; while(s < e){ int mid = (s+e+1)/2; if(num1[mid] > num1t) e = mid-1; else s = mid; } return c[s]; } else return c[reti]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 764 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 780 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 974 ms | 784 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 640 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |