# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
601157 | Jarif_Rahman | Flights (JOI22_flights) | C++17 | 51 ms | 3060 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 pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
namespace {
int n;
vector<vector<int>> v;
vector<int> sth;
int c;
void dfs(int nd, int ss){
int sz = v[nd].size();
if(ss != -1) sz--;
sth.pb(sz);
SetID(nd, c);
c++;
for(int x: v[nd]) if(x != ss) dfs(x, nd);
}
}
void Init(int N, vector<int> U, vector<int> V){
n = N;
v.assign(n, {});
for(int i = 0; i < n-1; i++) v[U[i]].pb(V[i]), v[V[i]].pb(U[i]);
sth.clear();
c = 0;
dfs(0, -1);
}
str SendA(str s){
str rt = "";
for(int i = 0; i < n; i++){
if(sth[i] == 0) rt+="00";
else if(sth[i] == 1) rt+="01";
else if(sth[i] == 2) rt+="10";
else rt+="11";
}
return rt;
}
#include "Benjamin.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
namespace {
int n, X, Y;
str s;
vector<vector<int>> v;
int ans;
int dfs1(int nd, int ss){
if(ss != -1) v[nd].pb(ss), v[ss].pb(nd);
int sz;
if(s[2*nd] == '0' && s[2*nd+1] == '0') sz = 0;
else if(s[2*nd] == '0' && s[2*nd+1] == '1') sz = 1;
else if(s[2*nd] == '1' && s[2*nd+1] == '0') sz = 2;
else sz = 3;
int nxt = nd+1;
for(int i = 1; i <= sz; i++){
nxt = dfs1(nxt, nd);
}
return nxt;
}
void dfs2(int nd, int ss, int d){
if(nd == Y) ans = d;
for(int x: v[nd]) if(x != ss) dfs2(x, nd, d+1);
}
}
str SendB(int n, int X, int Y){
::n = n, ::X = X, ::Y = Y;
return str(20, '1');
}
int Answer(str s){
::s = s;
v.assign(n, {});
dfs1(0, -1);
dfs2(X, -1, 0);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |