# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
567842 | dantoh000 | Flights (JOI22_flights) | C++17 | 160 ms | 1372 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>
using namespace std;
namespace {
int N;
vector<int> G[10005];
int d[10005];
}
void Init(int _N, std::vector<int> U, std::vector<int> V) {
N = _N;
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]);
}
for (int i = 0; i < N; i++){
SetID(i, i);
}
}
void dfs(int u, int p){
for (auto v : G[u]){
if (v == p) continue;
d[v] = d[u]+1;
dfs(v,u);
}
}
int findDist(int U, int V){
d[U] = 0;
dfs(U, -1);
///printf("dist between %d and %d is %d\n",U,V,d[V]);
return d[V];
}
std::string SendA(std::string S) {
int ID = 0;
for (int i = 0; i < 20; i++){
ID *= 2;
ID += (S[i]-'0');
}
string T = "";
ID <<= 6;
for (int j = 0; j < 64; j++){
int TARGET = ID + j;
int CUR = 0;
for (int i = 0; i < N; i++){
if (CUR + i > TARGET){
int X = i, Y = TARGET-CUR;
int D = findDist(X,Y);
for (int k = 12; k >= 0; k--){
T += (char)((D>>k&1)+'0');
}
break;
}
CUR += i;
}
}
///cout << "Ali sending " << T << endl;
return T;
}
#include "Benjamin.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int ID = 0;
}
std::string SendB(int N, int X, int Y) {
ID = 0;
if (X < Y) swap(X,Y);
for (int i = 0; i < X; i++){
ID += i;
}
ID += Y;
string s = "";
for (int i = 25; i > 5; i--){
s += (char)((ID>>i&1)+'0');
}
///cout << "Ben sending " << s << " " << ID << endl;
return s;
}
int Answer(std::string T) {
int offset = ID&(0b111111);
int ans = 0;
for (int i = offset*13; i < offset*13+13; i++){
ans *= 2;
ans += (T[i]-'0');
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |