# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
558035 | DanShaders | Flights (JOI22_flights) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//bs:flags:grader.cpp
#include "Ali.h"
#include "Benjamin.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
namespace x = __gnu_pbds;
template <typename T>
using ordered_set = x::tree<T, x::null_type, less<T>, x::rb_tree_tag, x::tree_order_statistics_node_update>;
template <typename T>
using normal_queue = priority_queue<T, vector<T>, greater<>>;
#define all(x) begin(x), end(x)
#define sz(x) ((int) (x).size())
#define x first
#define y second
using ll = long long;
using ld = long double;
const int N = 1e4 + 10;
int n;
vector<int> g[N];
void Init(int n_, vector<int> u, vector<int> v) {
n = n_;
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);
}
}
int get_forward(int x, int y) {
return y * (y + 1) / 2 + x;
}
pair<int, int> get_backward(int num) {
int lef = 0, rig = n;
while (rig - lef > 1) {
int mid = (lef + rig) / 2;
if (mid * (mid + 1) / 2 <= num) {
lef = mid;
} else {
rig = mid;
}
}
return {num - lef * (lef + 1) / 2, lef};
}
int dfs(int u, int w, int p = -1) {
if (u == w) {
return 0;
}
for (int v : g[u]) {
if (v != p) {
int ans = dfs(v, w, u);
if (ans != -1) {
return ans + 1;
}
}
}
return -1;
}
string SendA(string s) {
int msk = 0;
for (int i = 0; i < 20; ++i) {
msk |= (s[i] - '0') << (19 - i);
}
ostringstream oss;
while (msk < get_forward(0, n)) {
auto [x, y] = get_backward(msk);
oss << bitset<14>(dfs(x, y));
msk += (1 << 20);
}
return oss.str();
}
int x, y;
string SendB(int n_, int x_, int y_) {
n = n_, x = x_, y = y_;
if (x > y) {
swap(x, y);
}
return (ostringstream{} << bitset<20>(get_forward(x, y) % (1 << 20))).str();
}
int Answer(string t) {
int where = get_forward(x, y) / (1 << 20);
int msk = 0;
for (int i = 0; i < 14; ++i) {
msk |= (t[where * 14 + i] - '0') << (13 - i);
}
return msk;
}
//bs:flags:grader.cpp
#include "Ali.h"
#include "Benjamin.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
namespace x = __gnu_pbds;
template <typename T>
using ordered_set = x::tree<T, x::null_type, less<T>, x::rb_tree_tag, x::tree_order_statistics_node_update>;
template <typename T>
using normal_queue = priority_queue<T, vector<T>, greater<>>;
#define all(x) begin(x), end(x)
#define sz(x) ((int) (x).size())
#define x first
#define y second
using ll = long long;
using ld = long double;
const int N = 1e4 + 10;
int n;
vector<int> g[N];
void Init(int n_, vector<int> u, vector<int> v) {
n = n_;
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);
}
}
int get_forward(int x, int y) {
return y * (y + 1) / 2 + x;
}
pair<int, int> get_backward(int num) {
int lef = 0, rig = n;
while (rig - lef > 1) {
int mid = (lef + rig) / 2;
if (mid * (mid + 1) / 2 <= num) {
lef = mid;
} else {
rig = mid;
}
}
return {num - lef * (lef + 1) / 2, lef};
}
int dfs(int u, int w, int p = -1) {
if (u == w) {
return 0;
}
for (int v : g[u]) {
if (v != p) {
int ans = dfs(v, w, u);
if (ans != -1) {
return ans + 1;
}
}
}
return -1;
}
string SendA(string s) {
int msk = 0;
for (int i = 0; i < 20; ++i) {
msk |= (s[i] - '0') << (19 - i);
}
ostringstream oss;
while (msk < get_forward(0, n)) {
auto [x, y] = get_backward(msk);
oss << bitset<14>(dfs(x, y));
msk += (1 << 20);
}
return oss.str();
}
int x, y;
string SendB(int n_, int x_, int y_) {
n = n_, x = x_, y = y_;
if (x > y) {
swap(x, y);
}
return (ostringstream{} << bitset<20>(get_forward(x, y) % (1 << 20))).str();
}
int Answer(string t) {
int where = get_forward(x, y) / (1 << 20);
int msk = 0;
for (int i = 0; i < 14; ++i) {
msk |= (t[where * 14 + i] - '0') << (13 - i);
}
return msk;
}