# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
309814 | 2020-10-04T15:05:36 Z | tjdgus4384 | Stations (IOI20_stations) | C++14 | 961 ms | 768 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 = max(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-1;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; for(int i = 1;i < c.size();i++){ num2[i] = c[i]%1000; num1[i] = (c[i]-num2[i])/1000; } 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[0]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 512 KB | Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 512 KB | Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 560 KB | Invalid labels (duplicates values). scenario=1, label=0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 961 ms | 768 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 508 KB | Invalid labels (duplicates values). scenario=1, label=0 |
2 | Halted | 0 ms | 0 KB | - |