#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
void check(bool bl)
{
if(bl==0)
while(1);
}
vector<int> con[1005];
int idk[1005],timer;
void dfs(int nod, int par, int depth)
{
if(depth%2==0)
idk[nod] = timer++;
for(int adj:con[nod])
if(adj!=par)
dfs(adj,nod,depth+1);
if(depth%2==1)
idk[nod] = timer++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v)
{
for(int i=0;i<n;i++)
con[i].clear();
for(int i=0;i<u.size();i++)
{
con[u[i]].push_back(v[i]);
con[v[i]].push_back(u[i]);
}
timer=0;
dfs(0,-1,0);
vector<int> sol(n);
for(int i=0;i<n;i++)
{
sol[i] = idk[i];
}
sol[0]=0;
return sol;
}
int find_next_station(int s, int t, std::vector<int> c)
{
if((int)c.size() == 1)
return c[0];
if(s < c[0])//s e tin
{
if(s <= t && t <= c.back())
{
for(int i=0;i<c.size();i++)
if(c[i] >= t)
return c[i];
}
else
return c.back();
}
else//s e tout
{
if(c[0] <= t && t <= s)
{
for(int i=1;i<c.size();i++)
if(c[i] > t)
return c[i-1];
}
else
return c[0];
}
}
/*
1
7 6
0 2
2 1
1 3
0 4
4 5
5 6
6
0 3 2
0 1 2
0 2 2
0 6 4
0 5 4
0 4 4
*/
컴파일 시 표준 에러 (stderr) 메시지
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
70 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |