#include "stations.h"
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
vector<int> graph[1005];
int lst;
void dfs(int nod,int tata,int lvl,vector<int> &labels){
lst++;
if(lvl == 0){
labels[nod] = lst;
}
for(auto it:graph[nod]){
if(it == tata){
continue;
}
dfs(it,nod,lvl ^ 1,labels);
}
lst++;
if(lvl == 1){
labels[nod] = lst;
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> labels(n);
for (int i = 0; i < n; i++) {
graph[u[i]].push_back(v[i]);
graph[v[i]].push_back(u[i]);
}
dfs(0,-1,0,labels);
map<int,int> to_norm;
for(auto it:labels){
to_norm[it] = 0;
}
int lst = 0;
for(auto &it:to_norm){
it.second = ++lst;
}
for(auto &it:labels){
it = to_norm[it];
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
sort(c.begin(),c.end());
if(s < c[0]){
int father = c.back();
c.pop_back();
if(t < s){
return father;
}
for(int i = 0;i < (int)c.size();i++){
if(c[i] >= t){
return c[i];
}
}
return father;
}
else{
reverse(c.begin(),c.end());
int father = c.back();
c.pop_back();
reverse(c.begin(),c.end());
if(t > s){
return father;
}
for(int i = (int)c.size() - 1;i >= 0;i--){
if(c[i] <= t){
return c[i];
}
}
return father;
}
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3040 ms |
2808 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1468 ms |
2097156 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
986 ms |
892 KB |
Output is correct |
2 |
Runtime error |
1 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1255 ms |
2097156 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |