# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078461 | Trumling | Stations (IOI20_stations) | C++14 | 634 ms | 776 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.
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 99999999999999999
#define MOD 1000000007
#define all(x) x.begin(),x.end()
vector<vector<ll>>g;
vector<int> Labels;
void dfs(int start,int pre)
{
Labels[start]=(1<<start);
for(auto x:g[start])
if(x!=pre)
{
dfs(x,start);
Labels[start]|=Labels[x];
}
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
g.assign(n,vector<ll>());
Labels.assign(n,0);
for (int i = 0; i < n-1; i++) {
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
dfs(0,0);
for(int i=0;i<n;i++)
Labels[i]+=i*256;
return Labels;
}
int find_next_station(int s, int t, vector<int> c) {
ll S=s/256;
ll T=t/256;
ll par;
vector<ll>v;
for(auto x:c)
{
if((1<<S)&x)
par=x;
if((1<<T)&x)
v.pb(x);
}
if(S==0)
return v[0];
if(v.size()<=1)
return par;
return v[0] - par + v[1];
}
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... |