# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
711042 | minhcool | Flights (JOI22_flights) | C++17 | 354 ms | 9836 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;
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 3e5 + 5;
const int mod = 1e9 + 7, oo = 1e18 + 7;
vector<int> Adj[N];
int d[N], anc[N][20];
void dfs(int u, int p){
for(auto v : Adj[u]){
if(v == p) continue;
d[v] = d[u] + 1;
anc[v][0] = u;
for(int i = 1; i <= 19; i++) anc[v][i] = anc[anc[v][i - 1]][i - 1];
dfs(v, u);
}
}
int lca(int x, int y){
if(d[x] > d[y]) swap(x, y);
for(int i = 19; i >= 0; i--){
if(d[y] >= (d[x] + (1LL << i))) y = anc[y][i];
}
if(x == y) return x;
for(int i = 19; i >= 0; i--){
if(anc[x][i] != anc[y][i]){
x = anc[x][i], y = anc[y][i];
}
}
return anc[x][0];
}
int n;
int dist(int x, int y){
if(x > n || y > n) return 0;
return d[x] + d[y] - 2 * d[lca(x, y)];
}
void Init(int N, vector<int> U, vector<int> V) {
/*
variable_example++;
SetID(0, 0);
SetID(1, 1);
SetID(2, 2 * N + 19);*/
n = N;
for(int i = 0; i < n; i++) Adj[i].clear();
for(int i = 0; i < (n - 1); i++){
Adj[U[i]].pb(V[i]);
Adj[V[i]].pb(U[i]);
}
dfs(0, 0);
//cout << dist(5883, 4764) << "\n";
for(int i = 0; i < n; i++) SetID(i, i);
}
string SendA(string S) {
int temp0 = 0, temp1 = 0;
for(int i = 0; i < 10; i++) if(S[i] == '1') temp0 |= (1LL << i);
for(int i = 0; i < 10; i++) if(S[i + 10] == '1') temp1 |= (1LL << i);
temp0 *= 10, temp1 *= 10;
string ans = "";
for(int i = 0; i < 10; i++){
for(int j = 0; j < 10; j++){
int temp = dist(temp0 + i, temp1 + j);
//cout << temp0 + i << " " << temp1 + j << " " << temp << "\n";
for(int k = 0; k < 14; k++){
if(temp & (1LL << k)) ans += "1";
else ans += "0";
}
}
}
return ans;
}
#include "Benjamin.h"
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 3e5 + 5;
const int mod = 1e9 + 7, oo = 1e18 + 7;
int x, y;
string SendB(int N, int X, int Y) {
x = X, y = Y;
int temp0 = X / 10, temp1 = Y / 10;
string s;
for(int i = 0; i < 10; i++){
if(!(temp0 & (1LL << i))) s += "0";
else s += "1";
}
for(int i = 0; i < 10; i++){
if(!(temp1 & (1LL << i))) s += "0";
else s += "1";
}
return s;
}
int Answer(string T) {
int tol = ((x % 10) * 10) + (y % 10), ans = 0;
for(int i = tol * 14; i < (tol + 1) * 14; i++){
if(T[i] == '1') ans += (1LL << (i - tol * 14));
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |