#include <bits/stdc++.h>
using namespace std;
int const N=1005;
vector<int> adj[N];
int tim=-1;
int in[N],out[N];
void dfs(int node,int par=-1){
tim++;
in[node]=tim;
for(int i:adj[node])
if(i!=par)
dfs(i,node);
out[node]=tim;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
for (int i = 0; i < n; ++i)
{
adj[i].clear();
tim=-1;
in[i]=out[i]=0;
}
for (int i = 0; i < n-1; ++i)
{
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0);
vector<int> val;
for (int i = 0; i < n; ++i)
val.push_back((in[i]*1000)+out[i]);
// for(int i=0;i<n;i++)
// cout<<val[i]<<' ';
// cout<<endl;
return val;
}
int find_next_station(int s, int t, vector<int> c){
// cout<<s<<' '<<t<<endl;
int n=c.size();
int inn[n],outt[n];
int ti=t/1000,to=t%1000;
for (int i = 0; i < n; ++i)
{
inn[i]=c[i]/1000;
outt[i]=c[i]%1000;
// cout<<inn[i]<<' '<<outt[i]<<endl;
}
// cout<<"target "<<ti<<' '<<to<<endl;
for(int i=0;i<n;i++)
if(inn[i]<=ti && to<=outt[i])
return c[i];
int si=s/1000,so=s%1000;
// cout<<"source "<<si<<' '<<so<<endl;
for(int i=0;i<n;i++)
if(inn[i]<=si && so<=outt[i])
return c[i];
// cerr<<"it is not working"<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 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 |
2 ms |
344 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 |
332 ms |
684 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
609 ms |
684 KB |
Output is correct |
2 |
Incorrect |
451 ms |
684 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
348 ms |
684 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |