# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642431 | lis05st | Stations (IOI20_stations) | C++17 | 1 ms | 392 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifdef LIS05ST
#define _GLIBCXX_DEBUG
#define _GLIBCXX_DEBUG_PEDANTIC
#endif
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2,popcnt,lzcnt,bmi,bmi2")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
const int NMAX=1000;
vector<int>g[NMAX+5];
int p[NMAX+5];
int lbl[NMAX+5];
bool used[NMAX+5];
void dfs(int v,int l){
lbl[v]=l;
used[v]=1;
for(auto u:g[v]){
if(used[u])continue;
dfs(u,l+1);
}
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v){
memset(used,0,sizeof used);
memset(p,0,sizeof p);
for(int i=0;i<n;i++)g[i].clear();
for(int i=0;i<n-1;i++){
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
p[v[i]]++;
p[u[i]]++;
}
bool f=1;
for(int i=0;i<n;i++){
if(p[i]==1){
f=0;
dfs(i,0);
break;
}
}
//assert(f==0);
vector<int>ans(n);
for(int i=0;i<n;i++)ans[i]=lbl[i];
for(auto e:ans)cout<<e<<" ";
return ans;
};
int find_next_station(int s, int t, std::vector<int> c){
for(auto u:c){
if(s<=u&&u<=t)return u;
if(t<=u&&u<=s)return u;
}
};
#define MULTITESTS false
void solve(int testCase){
}
void precalc(){
}
/*
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
precalc();
int t=1;
if(MULTITESTS)cin>>t;
for(int i=1;i<=t;i++){
auto t1=clock();
solve(i);
auto t2=clock();
float delta=t2-t1;
delta/=CLOCKS_PER_SEC;
#ifdef LIS05ST
cout<<"("<<i<<")------------"<<fixed<<setprecision(2)<<delta<<"s\n";
#endif
}
}*/
Compilation message (stderr)
# | 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... |