# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1115128 | thelegendary08 | Flights (JOI22_flights) | C++17 | 1 ms | 332 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 "Ali.h"
#include<bits/stdc++.h>
#define f0r(i,n) for(int i = 0; i<n; i++)
#define pb push_back
#define vi vector<int>
#define FOR(i, k, n) for(int i = k; i< n; i++)
using namespace std;
namespace {
int n;
vector<vi>adj;
vi par;
void dfs(int x, int from){
for(auto u : adj[x]){
if(u != from){
par[u] = x;
dfs(u,x);
}
}
}
}
void Init(int N, std::vector<int> U, std::vector<int> V) {
n = N;
f0r(i,N){
SetID(i,i);
}
adj.resize(N);
par.resize(N);
f0r(i,N-1){
adj[U[i]].pb(V[i]);
adj[V[i]].pb(U[i]);
}
dfs(0,-1);
}
std::string SendA(std::string S) {
string s;
FOR(i, 1, n){
int cur = par[i];
f0r(j, 14){
if((1 << j) & cur){
s += '1';
}
else s += '0';
}
}
return s;
}
#include "Benjamin.h"
#include<bits/stdc++.h>
#define f0r(i,n) for(int i = 0; i<n; i++)
#define pb push_back
#define vi vector<int>
#define FOR(i, k, n) for(int i = k; i< n; i++)
using namespace std;
namespace {
int n;
int x,y;
vi par;
vi dist;
vector<vi>adj;
void dfs(int x, int from){
for(auto u : adj[x]){
if(u != from){
dist[u] = dist[x] + 1;
dfs(u,x);
}
}
}
}
std::string SendB(int N, int X, int Y) {
n = N;
x = X;
y = Y;
string s;
f0r(i, 20)s += '0';
return s;
}
int Answer(std::string T) {
par.resize(n);
dist.resize(n);
adj.resize(n);
f0r(i,n)dist[i] = 1e9;
for(int i = 0; i<T.size(); i+=14){
int cur = 0;
FOR(j, i, i+14){
cur += (T[j] - '0') * (j - i);
}
par[i+1] = cur;
adj[i+1].pb(cur);
adj[cur].pb(i+1);
}
par[0] = -1;
dist[x] = 0;
dfs(x,-1);
return dist[y];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |