This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const ll maxn=1e5+50;
const ll mod=1e9+7 ;
const ll base=1e9;
/// top 6 VietNam in APIO please god i am so fucking depressed
/// goal 6/7
#include "stations.h"
ll res[maxn];
ll cnt=0;
vector<ll> adj[maxn];
void dfs(ll u,ll par,ll t)
{
if (t%2) cnt++,res[u]=cnt;
for (auto to:adj[u])
{
if (to==par) continue;
dfs(to,u,t+1);
}
if ((t%2)==0) cnt++,res[u]=cnt;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for (int i=1;i<=n-1;i++)
{
ll x=u[i-1];
ll y=v[i-1];
x++;
y++;
adj[x].pb(y);
adj[y].pb(x);
}
cnt=0;
dfs(1,0,0);
vector<ll> ans;
for (int i=1;i<=n;i++) ans.pb(res[i]-1),adj[i].clear();
return ans;
}
int find_next_station(int s, int t, vector<int> c) {
if (s<c[0])
{
sort(c.begin(),c.end());
for (int i=0;i+1<c.size();i++)
{
if (t>=s&&t<=c[i]) return c[i];
}
return c.back();
}
else
{
sort(c.begin(),c.end());
c.pb(s);
for (int i=1;i+1<c.size();i++)
{
if (t>=c[i]&&t<c[i+1]) return c[i];
}
return c[0];
}
}
/*int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
if (fopen("CONVEXHULL.inp", "r"))
{
freopen("CONVEXHULL.inp", "r", stdin);
freopen("CONVEXHULL.out", "w", stdout);
}
}*/
Compilation message (stderr)
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:57:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for (int i=0;i+1<c.size();i++)
| ~~~^~~~~~~~~
stations.cpp:67:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for (int i=1;i+1<c.size();i++)
| ~~~^~~~~~~~~
# | 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... |