提出 #49559724
ソースコード 拡げる
#include <bits/stdc++.h>
typedef long long valueType;
typedef std::vector<valueType> ValueVector;
typedef std::vector<ValueVector> ValueMatrix;
typedef std::vector<ValueMatrix> ValueCube;
typedef std::string string;
typedef std::vector<string> StringVector;
typedef std::vector<bool> bitset;
typedef std::vector<bitset> BitMatrix;
typedef std::pair<valueType, valueType> ValuePair;
typedef std::vector<ValuePair> PairVector;
typedef std::vector<PairVector> PairMatrix;
typedef std::tuple<valueType, valueType, valueType> ValueTuple;
typedef std::vector<ValueTuple> TupleVector;
typedef std::vector<TupleVector> TupleMatrix;
typedef std::set<valueType> ValueSet;
typedef std::pair<valueType, valueType> ValuePair;
typedef std::vector<ValuePair> PairVector;
typedef std::set<ValuePair> PairSet;
void solve() {
valueType N;
std::cin >> N;
ValueVector A(N), B(N);
for (auto &a : A)
std::cin >> a;
for (auto &b : B)
std::cin >> b;
std::sort(A.begin(), A.end());
std::sort(B.begin(), B.end());
if (A[N - 1] + A[N - 2] <= B.back()) {
std::cout << "Bob\n";
return;
}
// A.erase(std::unique(A.begin(), A.end()), A.end());
auto Count = [&](valueType l, valueType r) -> valueType { // count number of elements in (l, r) of A
++l;
--r;
if (l > r)
return 0;
return std::upper_bound(A.begin(), A.end(), r) - std::lower_bound(A.begin(), A.end(), l);
};
auto Check = [&](valueType l, valueType r, valueType a) -> bool {
if (l < a && a < r) {
return Count(l, r) > 1;
} else {
return Count(l, r) > 0;
}
};
ValueVector LimitB(N, 0);
for (valueType i = 0; i < N; ++i) {
valueType const b = B[i];
auto iter = std::lower_bound(A.begin(), A.end(), b);
if (iter != A.end()) {
LimitB[i] = *iter - b;
}
if (iter != A.begin()) {
--iter;
LimitB[i] = std::max(LimitB[i], b - *iter);
}
}
ValueVector SufMaxOfLimitB = LimitB;
for (valueType i = N - 2; i >= 0; --i)
SufMaxOfLimitB[i] = std::max(SufMaxOfLimitB[i], SufMaxOfLimitB[i + 1]);
bool ok = false;
valueType pointer = 0;
valueType const MinB = B.front();
for (auto const &a : A) {
while (pointer < N && B[pointer] < a)
++pointer;
bool flag = true;
if (pointer != N) {
if (a <= SufMaxOfLimitB[pointer])
flag = false;
}
if (std::lower_bound(B.begin(), B.end(), a) != B.end()) {
valueType nextB = *std::lower_bound(B.begin(), B.end(), a);
valueType const l = nextB - a;
valueType const r = nextB + a;
if (!Check(l, r, a))
flag = false;
}
if (std::upper_bound(B.begin(), B.end(), a) != B.end()) {
valueType nextB = *std::upper_bound(B.begin(), B.end(), a);
valueType const l = nextB - a;
valueType const r = nextB + a;
if (!Check(l, r, a))
flag = false;
}
if (MinB < a) {
if (!Check(a - MinB, a + MinB, a))
flag = false;
}
if (flag) {
ok = true;
break;
}
}
std::cout << (ok ? "Alice" : "Bob") << '\n';
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
valueType T;
std::cin >> T;
for (valueType testcase = 0; testcase < T; ++testcase)
solve();
std::cout << std::flush;
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Triangle Card Game |
| ユーザ | UserUnauthorized |
| 言語 | C++ 20 (gcc 12.2) |
| 得点 | 0 |
| コード長 | 3820 Byte |
| 結果 | WA |
| 実行時間 | 82 ms |
| メモリ | 9520 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 700 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_01.txt |
| All | 00_sample_01.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt, 02_handmade_07.txt, 02_handmade_08.txt, 02_handmade_09.txt, 02_handmade_10.txt, 02_handmade_11.txt, 02_handmade_12.txt, 02_handmade_13.txt, 02_handmade_14.txt, 02_handmade_15.txt, 02_handmade_16.txt, 02_handmade_17.txt, 02_handmade_18.txt, 02_handmade_19.txt, 02_handmade_20.txt, 02_handmade_21.txt, 02_handmade_22.txt, 02_handmade_23.txt, 02_handmade_24.txt, 02_handmade_25.txt, 02_handmade_26.txt, 02_handmade_27.txt, 02_handmade_28.txt, 02_handmade_29.txt, 02_handmade_30.txt, 02_handmade_31.txt, 02_handmade_32.txt, 02_handmade_33.txt, 02_handmade_34.txt, 02_handmade_35.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_01.txt | AC | 1 ms | 3436 KiB |
| 01_test_01.txt | AC | 52 ms | 7404 KiB |
| 01_test_02.txt | WA | 50 ms | 5952 KiB |
| 01_test_03.txt | AC | 51 ms | 6696 KiB |
| 01_test_04.txt | AC | 51 ms | 5824 KiB |
| 01_test_05.txt | AC | 52 ms | 6992 KiB |
| 01_test_06.txt | WA | 51 ms | 6860 KiB |
| 01_test_07.txt | AC | 52 ms | 7508 KiB |
| 01_test_08.txt | AC | 53 ms | 9112 KiB |
| 01_test_09.txt | AC | 52 ms | 7824 KiB |
| 01_test_10.txt | AC | 52 ms | 7336 KiB |
| 01_test_11.txt | WA | 40 ms | 3664 KiB |
| 01_test_12.txt | WA | 41 ms | 3580 KiB |
| 01_test_13.txt | WA | 41 ms | 3668 KiB |
| 01_test_14.txt | WA | 41 ms | 3664 KiB |
| 01_test_15.txt | WA | 41 ms | 3644 KiB |
| 01_test_16.txt | WA | 41 ms | 3632 KiB |
| 01_test_17.txt | WA | 40 ms | 3652 KiB |
| 01_test_18.txt | AC | 40 ms | 3656 KiB |
| 01_test_19.txt | AC | 40 ms | 3640 KiB |
| 01_test_20.txt | WA | 41 ms | 3524 KiB |
| 02_handmade_01.txt | AC | 43 ms | 6148 KiB |
| 02_handmade_02.txt | WA | 28 ms | 3516 KiB |
| 02_handmade_03.txt | WA | 29 ms | 3488 KiB |
| 02_handmade_04.txt | WA | 28 ms | 3512 KiB |
| 02_handmade_05.txt | WA | 28 ms | 3504 KiB |
| 02_handmade_06.txt | WA | 28 ms | 3368 KiB |
| 02_handmade_07.txt | WA | 30 ms | 3584 KiB |
| 02_handmade_08.txt | WA | 30 ms | 3440 KiB |
| 02_handmade_09.txt | WA | 30 ms | 3512 KiB |
| 02_handmade_10.txt | WA | 30 ms | 3408 KiB |
| 02_handmade_11.txt | WA | 29 ms | 3504 KiB |
| 02_handmade_12.txt | WA | 30 ms | 3584 KiB |
| 02_handmade_13.txt | AC | 71 ms | 9520 KiB |
| 02_handmade_14.txt | AC | 23 ms | 6352 KiB |
| 02_handmade_15.txt | AC | 82 ms | 9516 KiB |
| 02_handmade_16.txt | AC | 69 ms | 9520 KiB |
| 02_handmade_17.txt | AC | 58 ms | 4660 KiB |
| 02_handmade_18.txt | AC | 62 ms | 4928 KiB |
| 02_handmade_19.txt | AC | 62 ms | 4560 KiB |
| 02_handmade_20.txt | AC | 62 ms | 4664 KiB |
| 02_handmade_21.txt | AC | 21 ms | 4040 KiB |
| 02_handmade_22.txt | AC | 21 ms | 3904 KiB |
| 02_handmade_23.txt | AC | 20 ms | 3828 KiB |
| 02_handmade_24.txt | AC | 79 ms | 4456 KiB |
| 02_handmade_25.txt | AC | 76 ms | 4572 KiB |
| 02_handmade_26.txt | AC | 77 ms | 4604 KiB |
| 02_handmade_27.txt | AC | 65 ms | 4564 KiB |
| 02_handmade_28.txt | AC | 63 ms | 4784 KiB |
| 02_handmade_29.txt | AC | 63 ms | 4128 KiB |
| 02_handmade_30.txt | AC | 51 ms | 4532 KiB |
| 02_handmade_31.txt | AC | 54 ms | 4700 KiB |
| 02_handmade_32.txt | AC | 48 ms | 4420 KiB |
| 02_handmade_33.txt | AC | 56 ms | 4908 KiB |
| 02_handmade_34.txt | AC | 63 ms | 4580 KiB |
| 02_handmade_35.txt | AC | 60 ms | 4712 KiB |