QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#149406 | #6335. Belt Conveyor | JCY_ | 11 | 70ms | 35696kb | C++17 | 2.0kb | 2023-08-24 15:50:46 | 2023-08-24 15:50:49 |
Judging History
answer
#include "conveyor.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i128 = __int128;
using u128 = unsigned __int128;
template <typename T>
void chkmax(T &x, const T &y) {
if (x < y) x = y;
}
template <typename T>
void chkmin(T &x, const T &y) {
if (y < x) x = y;
}
void Solve(int n, vector<int> A, vector<int> B) {
vector<vector<pair<int, int>>> g(n);
for (int i = 0; i < n - 1; ++i) {
g[A[i]].emplace_back(B[i], i);
g[B[i]].emplace_back(A[i], i);
}
vector<int> buc[3], ans(n - 1, -1);
function<void(int, int, int)> dfs = [&](int u, int pre, int d) {
buc[d].emplace_back(u);
for (auto &e : g[u]) {
int v = e.first;
if (v == pre) continue;
dfs(v, u, d == 2 ? 0 : d + 1);
}
};
dfs(0, -1, 0);
int num[3];
while (find(ans.begin(), ans.end(), -1) != ans.end()) {
fill(num, num + 3, 0);
for (int d = 0; d < 3; ++d) {
for (auto u : buc[d]) {
bool have = false;
for (auto &e : g[u]) {
int id = e.second;
if (ans[id] == -1) {
have = true;
break;
}
}
num[d] += have;
}
}
int d = max_element(num, num + 3) - num;
vector<int> x(n - 1), y(n);
for (auto u : buc[d]) {
y[u] = 1;
for (auto &e : g[u]) {
int id = e.second;
if (ans[id] != -1) x[id] = ans[id] ^ (A[id] == u);
}
}
vector<int> z = Query(x, y);
for (auto u : buc[d]) {
if (z[u]) {
for (auto &e : g[u]) {
int id = e.second;
if (ans[id] == -1) ans[id] = (A[id] == u);
}
} else {
for (auto &e : g[u]) {
int v, id;
tie(v, id) = e;
if (z[v]) {
ans[id] = (B[id] == u);
break;
}
}
}
}
}
Answer(ans);
}
// g++ conveyor.cpp grader.cpp -o conveyor -Wall -Wextra -Wshadow -O2 -std=c++14 -fsanitize=address,undefined
詳細信息
Subtask #1:
score: 1
Accepted
Test #1:
score: 1
Accepted
time: 1ms
memory: 3704kb
input:
random1 2 0 1 1 0xC321A02965AC2640
output:
Accepted: 1
result:
ok correct
Test #2:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
random1 2 1 0 0 0x8A99AD9552B2C218
output:
Accepted: 1
result:
ok correct
Test #3:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
random1 2 1 0 1 0x024D21FA307D148D
output:
Accepted: 1
result:
ok correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
random1 2 0 1 0 0x3C96AB23CEB63F75
output:
Accepted: 1
result:
ok correct
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #5:
score: 14
Accepted
time: 1ms
memory: 3712kb
input:
priority 30 10 29 10 13 17 11 2 15 15 27 9 26 18 0 14 1 22 24 29 28 6 22 4 20 15 5 28 4 21 24 3 13 1 8 13 12 8 19 16 3 1 10 24 29 12 8 4 7 2 7 28 25 12 7 2 23 27 22 89058848 6377689 24189123 31671827 205117644 254374430 56016068 6819602 212866321 246625321 274047319 230485311 202854776 280075001 203...
output:
Accepted: 5
result:
ok correct
Test #6:
score: -14
Wrong Answer
time: 1ms
memory: 3720kb
input:
random1 30 18 20 12 0 13 2 9 11 24 7 15 26 17 19 23 10 20 16 3 11 24 1 18 19 1 28 22 6 6 26 21 5 27 27 14 15 8 0 17 5 16 3 10 29 13 14 25 28 25 23 8 9 4 2 4 12 7 22 1 0 0 0 1 0 0 1 0 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 1 1 0 1 0x139BEEDAC0AE4AFB
output:
Wrong Answer [8]
result:
wrong answer Token "Wrong" doesn't correspond to pattern "Accepted:"
Subtask #3:
score: 10
Accepted
Test #11:
score: 10
Accepted
time: 66ms
memory: 34352kb
input:
random1 100000 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 9...
output:
Accepted: 4
result:
ok correct
Test #12:
score: 0
Accepted
time: 60ms
memory: 34328kb
input:
priority 100000 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 ...
output:
Accepted: 4
result:
ok correct
Test #13:
score: 0
Accepted
time: 30ms
memory: 35696kb
input:
random1 100000 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 9...
output:
Accepted: 3
result:
ok correct
Test #14:
score: 0
Accepted
time: 70ms
memory: 34468kb
input:
priority 100000 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 ...
output:
Accepted: 4
result:
ok correct
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%