QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#877475 | #3505. Flights | duongnc000 | 15 | 1ms | 3840kb | C++20 | 2.3kb | 2025-01-31 22:36:05 | 2025-01-31 22:36:17 |
Judging History
Ali
#include "Ali.h"
#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define isz(x) (int)x.size()
using namespace std;
namespace {
int N;
vector<int> dep, ap;
vector<vector<int>> g;
vector<vector<pair<int, int>>> st;
void init_lca() {
st.assign(1, {});
ap.assign(N, 0);
dep.assign(N, 0);
}
void dfs(int u, int p) {
ap[u] = isz(st[0]);
st[0].emplace_back(dep[u], u);
for (auto v : g[u]) if (v != p) {
dep[v] = dep[u] + 1;
dfs(v, u);
st[0].emplace_back(dep[u], u);
}
}
void build_sparse() {
for (int p = 1, i = 1; p << 1 <= isz(st[0]); p <<= 1, ++i) {
st.emplace_back(isz(st[0]) - (p << 1) + 1);
for (int j = 0; j < isz(st[i]); ++j) {
st[i][j] = min(st[i - 1][j], st[i - 1][j + p]);
}
}
}
int LCA(int u, int v) {
int l = ap[u], r = ap[v];
if (l > r) swap(l, r);
++r;
int d = __lg(r - l);
return min(st[d][l], st[d][r - (1 << d)]).second;
}
int dist(int u, int v) {
return dep[u] + dep[v] - 2 * dep[LCA(u, v)];
}
}
void Init(int N, vector<int> U, vector<int> V) {
::N = N;
g.assign(N, {});
for (int i = 0; i < N - 1; ++i) {
int u = U[i], v = V[i];
g[u].emplace_back(v);
g[v].emplace_back(u);
}
for (int i = 0; i < N; ++i) {
SetID(i, i);
}
init_lca();
dfs(0, -1);
build_sparse();
}
string SendA(string S) {
int X = 0, Y = 0;
for (int i = 0; i < 14; ++i) X |= (S[i] - '0') << i;
for (int i = 0; i < 6; ++i) Y |= (S[i + 14] - '0') << i;
string res = "";
for (int i = Y; i < N; i += 1 << 6) {
int d = dist(X, i);
for (int j = 0; j < 14; ++j) res.push_back((d >> j & 1) + '0');
}
return res;
}
Benjamin
#include "Benjamin.h"
#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define isz(x) (int)x.size()
using namespace std;
namespace {
int Y;
}
string SendB(int N, int X, int Y) {
::Y = Y >> 6;
string res = "";
for (int i = 0; i < 14; ++i) res.push_back((X >> i & 1) + '0');
for (int i = 0; i < 6; ++i) res.push_back((Y >> i & 1) + '0');
return res;
}
int Answer(string T) {
int st = 14 * Y, res = 0;
for (int i = 0; i < 14; ++i) res |= (T[st + i] - '0') << i;
return res;
}
詳細信息
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 0ms
memory: 3840kb
input:
1 2 1 0 10000000000000
output:
10000000000000000000 1
input:
output:
1 14
result:
points 1.0 L = 14 (test case 1)
Test #2:
score: 15
Accepted
time: 1ms
memory: 3840kb
input:
1 3 2 0 01000000000000
output:
01000000000000000000 2
input:
output:
2 14
result:
points 1.0 L = 14 (test case 1)
Test #3:
score: 15
Accepted
time: 0ms
memory: 3584kb
input:
1 4 2 0 10000000000000
output:
01000000000000000000 1
input:
output:
1 14
result:
points 1.0 L = 14 (test case 1)
Test #4:
score: 15
Accepted
time: 0ms
memory: 3712kb
input:
1 5 4 0 10000000000000
output:
00100000000000000000 1
input:
output:
1 14
result:
points 1.0 L = 14 (test case 1)
Test #5:
score: 15
Accepted
time: 0ms
memory: 3840kb
input:
1 10000 2015 3582 100010000000000100100000000010010000000000001010000000000110100000000011001000000000011100000000001111000000000001011000000000000100000000000110100000000000101000000000000110000000001001100000000000101000000000001010000000000010100000000011001000000000011010000000001010100000000001...
output:
11111011111000011111 28
input:
output:
28 2184
result:
points 1.0 L = 2184 (test case 1)
Test #6:
score: 15
Accepted
time: 1ms
memory: 3712kb
input:
1 10000 1566 3236 010010000000001100100000000001001000000000001010000000000110100000000010101000000000101010000000001000100000000010001000000000000110000000000110100000000011101000000000011010000000000100100000000011101000000000110110000000001001100000000011101000000000000110000000001110100000000010...
output:
01111000011000001001 20
input:
output:
20 2184
result:
points 1.0 L = 2184 (test case 1)
Test #7:
score: 15
Accepted
time: 0ms
memory: 3840kb
input:
1 10000 1075 2327 100010000000000000100000000010001000000000001010000000001001100000000011101000000000001100000000000001100000000000101000000000110010000000000110100000000011011000000000001100000000000010100000000010011000000000010010000000001110100000000001101000000000010100000000000100100000000011...
output:
11001100001000111010 29
input:
output:
29 2184
result:
points 1.0 L = 2184 (test case 1)
Test #8:
score: 15
Accepted
time: 0ms
memory: 3840kb
input:
1 10000 564 1250 1110100000000011011000000000010110000000000011100000000001001000000000010110000000000000010000000011000000000000110010000000001001100000000011001000000000001010000000000101100000000000101000000000001110000000000100010000000001010000000000001010000000000011100000000011111000000000011...
output:
00101100010000010001 31
input:
output:
31 2184
result:
points 1.0 L = 2184 (test case 1)
Test #9:
score: 15
Accepted
time: 1ms
memory: 3840kb
input:
1 10000 7101 7258 001111000110000001010001000001111011000000111011000110000100100100010001011001010000010010100001000110000001010000100001011000100110010000001000011001010000001000100000000010111000001110000010100011011000100000111100000101001000000100000011010011010000101111001101000000100000000000...
output:
10111101110110010110 240
input:
output:
240 2184
result:
points 1.0 L = 2184 (test case 1)
Test #10:
score: 15
Accepted
time: 0ms
memory: 3712kb
input:
1 8191 5883 4764 1111000000000010101000000000001010000000000000100000000011001000000000110010000000001010100000000011001000000000010010000000000010100000000011101000000000011010000000001010100000000010101000000000101010000000001110100000000010101000000000101010000000000010100000000011001000000000101...
output:
11011111011010001110 23
input:
output:
23 1792
result:
points 1.0 L = 1792 (test case 1)
Test #11:
score: 15
Accepted
time: 1ms
memory: 3712kb
input:
1 9996 7917 2822 1011100000000001100100000000011110000000001010010000000000000100000000101101000000000001010000000010010100000000011110000000000111010000000011110100000000000011000000001101010000000000110100000000101101000000001001100000000000000100000000111001000000001000110000000001001100000000110...
output:
10110111011110011000 54
input:
output:
54 2198
result:
points 1.0 L = 2198 (test case 1)
Test #12:
score: 15
Accepted
time: 0ms
memory: 3840kb
input:
1 9996 8666 9326 0100010000000001111000000000111101000000000100010000000001001100000000110011000000000111010000000001100100000000111110000000000110110000000001101100000000111011000000000100110000000001001100000000110011000000000101010000000000001000000000110001000000000101110000000001011100000000110...
output:
01011011100001011101 70
input:
output:
70 2184
result:
points 1.0 L = 2184 (test case 1)
Test #13:
score: 15
Accepted
time: 0ms
memory: 3840kb
input:
1 10000 1948 534 1001101000000010011001000000001011100000001111001000000011110001000000010101100000001010001000000010100001000000000001100000000000010100000011011110000000011010100000000110100100000010001110000000001100100000000011000100000011100110000000010000100000000100000100000010111010000000000...
output:
00111001111000011010 96
input:
output:
96 2184
result:
points 1.0 L = 2184 (test case 1)
Test #14:
score: 15
Accepted
time: 0ms
memory: 3840kb
input:
1 10000 0 9999 111100000000001111001000000011110001000000111100110000001111000010000011110010100000111100011000001111001110000011110000010000111100100100001111000101000011110011010000111100001100001111001011000011110001110000111100111100001111000000100011110010001000111100010010001111001100100011110...
output:
00000000000000111100 9999
input:
output:
9999 2198
result:
points 1.0 L = 2198 (test case 1)
Test #15:
score: 15
Accepted
time: 1ms
memory: 3840kb
input:
1 9997 6367 7728 0010101111000011010011110000111111011100000110110111000001010101110000100001011100001010100111000000110001110000000000011100001110111011000010101110110000100101101100000000011011000000101010110000110100101100001111110011000001101100110000010101001100001000010011000010101000110000001...
output:
11111011000110000011 218
input:
output:
218 2184
result:
points 1.0 L = 2184 (test case 1)
Subtask #2:
score: 0
Wrong Answer
Test #16:
score: 0
Wrong Answer
time: 0ms
memory: 3840kb
input:
15 2 0 1 10000000000000 3 2 0 10000000000000 4 1 3 01000000000000 5 4 1 01000000000000 10000 8703 7108 01110000000000010010000000000100100000000010001000000000100010000000000110100000000001101000000000111010000000000010100000000010101000000000001010000000001100100000000011101000000000000110000000001...
output:
00000000000000100000 1 01000000000000000000 1 10000000000000110000 2 00100000000000100000 2 11111111100001001000 20 10011010111000111001 24 01111010101000111001 20 10111111010100110011 21 01010111001110111100 1866 11000111111110101110 20 11111110110110111001 50 00011000010001101001 62 11111001110100...
input:
output:
1 1 2 2 20 24 20 21 1866 20 50 62 172 9999 659 2198
result:
points 0.0 L = 2198 (test case 15)