# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
605411 | MohamedAliSaidane | Stations (IOI20_stations) | C++14 | 887 ms | 508 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
#define pb push_back
#define popb pop_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
vi label(int n, int k, vi u, vi v)
{
vi rep(n, -1);
rep[0] = 0;
vi adj[n];
for(int i= 0 ; i <n - 1; i ++)
{
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
}
queue<pii> q;
q.push({0,0});
while(!q.empty())
{
int node = q.front().ff;
int val = q.front().ss;
q.pop();
val = (val << 3) + node;
rep[node] = val;
for(auto e: adj[node])
{
if(rep[e] == -1)
{
q.push({e, val});
}
}
}
return rep;
}
int find_next_station(int s, int t, vi c)
{
set<int> part;
int cur = t;
int u = (s & 1) + (s & 2) + (s & 4);
int ot = s;
ot = ot >> 3;
int par = (ot & 1) + (ot & 2) + (ot & 4);
for(int i= 0; i < 8; i ++)
{
int v = (cur & 1) + (cur & 2) + (cur & 4);
part.insert(v);
cur = (cur >> 3);
}
if(part.count(u) != 0)
{
for(auto e: c)
{
int v = (e & 1) + (e & 2) + (e & 4);
if(part.count(v) != 0 && v != par)
return e;
}
}
else
{
for(auto e: c)
{
int v = (e & 1) + (e & 2) + (e & 4);
if(v == par)
return e;
}
}
}
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... |