QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#218841 | #4563. Radio Towers | bashkort | 0 | 60ms | 30552kb | C++20 | 2.8kb | 2023-10-18 19:14:53 | 2023-10-18 19:14:53 |
Judging History
answer
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
struct BinaryJumps {
vector<int> nxt, val;
vector<int> jump, depth, sum;
int n;
void build(vector<int> nx, vector<int> value, int type) {
n = size(nx);
nxt = std::move(nx), val = std::move(value);
jump.assign(n, -1), depth.assign(n, 0), sum.assign(n, 0);
auto init = [&](int i) {
if (nxt[i] == -1) {
jump[i] = i;
depth[i] = 0;
} else {
depth[i] = depth[nxt[i]] + 1;
int a = jump[nxt[i]];
int b = jump[a];
if (depth[nxt[i]] - depth[a] == depth[a] - depth[b]) {
jump[i] = b;
sum[i] = sum[nxt[i]] + sum[a];
} else {
jump[i] = nxt[i];
}
}
sum[i] += val[i];
};
if (type == 1) { // R => jump to the right
for (int i = n - 1; i >= 0; --i) {
init(i);
}
} else { // L => jump to the left
for (int i = 0; i < n; ++i) {
init(i);
}
}
}
} L, R;
struct SparseTable {
vector<vector<pair<int, int>>> mn;
void init(const vector<int> &a, int p = 1) {
int n = size(a);
mn.resize(__lg(n) + 1);
mn[0].resize(n);
for (int i = 0; i < n; ++i) {
mn[0][i] = {a[i] * p, i};
}
for (int b = 1; b < size(mn); ++b) {
mn[b].resize(n - (1 << b) + 1);
for (int i = 0; i <= n - (1 << b); ++i) {
mn[b][i] = min(mn[b - 1][i], mn[b - 1][i + (1 << b - 1)]);
}
}
}
pair<int, int> rangeMin(int l, int r) {
if (l >= r) {
return {2e9, -1};
}
int b = __lg(r - l);
return min(mn[b][l], mn[b][r - (1 << b)]);
}
} stMin, stMax;
int n;
vector<int> h, sumL, sumR, nxtL, nxtR, mx;
int build(int l, int r) {
if (l >= r) {
return 0;
}
int mid = stMax.rangeMin(l, r).second;
sumL[mid] = build(l, mid);
sumR[mid] = build(mid + 1, r);
mx[mid] = h[mid] - max(stMin.rangeMin(l, mid).first, stMin.rangeMin(mid + 1, r).first);
return 0; // sumL[mid] + sumR[mid] + (max(stMin.rangeMin(l, mid).first, stMin.rangeMin(mid + 1, r).first))
}
void init(int n, std::vector<int> H) {
::n = n;
::h = H;
sumL.assign(n, 0), sumR.assign(n, 0), nxtL.assign(n, -1), nxtR.assign(n, -1), mx.assign(n, 0);
stMax.init(H, -1);
stMin.init(H, 1);
build(0, n);
sort(mx.begin(), mx.end());
}
int max_towers(int L, int R, int D) {
return n - (lower_bound(mx.begin(), mx.end(), D) - mx.begin());
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 32ms
memory: 22984kb
input:
59640 49885 57346 58504 87383 113182 129676 204090 205404 259925 276583 300332 324014 333675 359377 364049 408489 414852 428310 438038 440113 458193 554789 643468 666525 683112 690791 707313 720088 741028 748785 789826 796576 800966 832867 851750 861044 862283 900756 926925 939560 955678 965636 9740...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
wrong answer 14th lines differ - expected: '2', found: '1'
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 3868kb
input:
425 753881706 405729786 890889563 29736246 598281970 208352067 357783003 663497023 178397034 4832890 562140755 510307001 354540290 538848551 436879256 86659033 42928516 24145404 749159097 118423198 506851985 204895765 719719998 726244368 991372008 681703480 799303017 657138050 88278945 417801236 260...
output:
130
result:
wrong answer 3rd lines differ - expected: '13', found: '130'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #65:
score: 0
Wrong Answer
time: 60ms
memory: 30552kb
input:
99308 491693640 24020487 317364185 726230755 737284540 951143270 709116045 641023337 360629062 964879440 47884022 532494780 803629825 635450854 688041998 573937055 113198481 191311841 929603572 636688 598629732 895342035 396521271 619919754 716589045 657789547 373121546 866402108 609316614 60046511 ...
output:
33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 33009 ...
result:
wrong answer 3rd lines differ - expected: '11903', found: '33009'
Subtask #5:
score: 0
Wrong Answer
Test #86:
score: 0
Wrong Answer
time: 22ms
memory: 9220kb
input:
23881 605288257 422163932 155875880 339929874 76049859 196344969 958160745 767945284 469191956 997116006 387749577 15911341 920437918 367576975 800789357 351557615 283723284 369507452 841548133 643412903 309731505 256549694 370065644 699518122 559017597 347646657 469353381 575240521 501893001 454519...
output:
7196 7062 149 5029 5226 7332 1777 6674 2011 5920 4877 7476 4597 2768 5359 6464 7659 7233 7793 2759 6320 7055 7301 4748 463 2028 5649 1972 6226 4899 4965 4989 3141 784 5817 3004 7704 6966 1939 5879 7200 4751 1277 6553 2950 893 6600 7018 7235 6075 5181 6578 2342 2069 4336 5743 4436 2261 6685 1738 7755...
result:
wrong answer 3rd lines differ - expected: '7197', found: '7196'
Subtask #6:
score: 0
Wrong Answer
Test #97:
score: 0
Wrong Answer
time: 35ms
memory: 27852kb
input:
88768 238644804 620122421 789364401 899010695 885388612 437964772 845379533 657562749 773925456 625793781 916240972 291506550 379611161 905077982 629848170 530056471 520438258 806293637 326792996 785404568 74285074 565304193 846963319 63529729 804909008 212070492 69936548 656129389 408708069 3070450...
output:
25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 25888 ...
result:
wrong answer 3rd lines differ - expected: '7293', found: '25888'
Subtask #7:
score: 0
Skipped
Dependency #1:
0%