QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#142274#4563. Radio TowersQwerty123217 75ms36128kbC++203.4kb2023-08-18 21:20:422023-08-18 21:20:44

Judging History

你现在查看的是最新测评结果

  • [2023-08-18 21:20:44]
  • 评测
  • 测评结果:17
  • 用时:75ms
  • 内存:36128kb
  • [2023-08-18 21:20:42]
  • 提交

answer

#include "towers.h"

#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <vector>

template <typename cmp_t>
struct ST {
    std::vector<std::vector<std::pair<int, int>>> data;

    ST() = default;
    ST(std::vector<int> vec) {
        int lg = std::__lg(vec.size()) + 1;
        data.resize(lg);
        data[0].resize(vec.size());
        for (int i = 0; i < vec.size(); i++) {
            data[0][i] = {vec[i], i};
        }
        for (int k = 1; k < lg; k++) {
            data[k].resize(vec.size() - (1 << k) + 1);
            for (int i = 0; i < data[k].size(); i++) {
                data[k][i] = std::min(data[k - 1][i], data[k - 1][i + (1 << k - 1)], cmp_t());
            }
        }
    }

    auto get_min(int l, int r) {
        int k = std::__lg(r - l);
        return std::min(data[k][l], data[k][r - (1 << k)], cmp_t());
    }
};

int n, q;
ST<std::less<>> st_min;
ST<std::greater<>> st_max;
std::vector<int> input;

std::vector<int> lvs;
std::vector<int> h_lca;
std::vector<int> shit;

void init(int n, std::vector<int> H) {
    q = 0;
    ::n = n;
    input = H;
    st_min = ST<std::less<>>(input);
    st_max = ST<std::greater<>>(input);

    h_lca.assign(n, -1);

    auto fuck = [&](auto fuck, int l, int r) -> std::pair<int, int> {
        if (l >= r) {
            return {int(1e9), (int)1e9};
        }
        if (l + 1 == r) {
            int rs = lvs.size();
            // lvs.push_back(l);
            // return {rs, rs};
            return {input[l], input[l]};
        }
        int id = st_max.get_min(l, r).second;
        auto [p1, p2] = fuck(fuck, l, id);
        auto [p3, p4] = fuck(fuck, id + 1, r);

        int a = std::min(p1, p2);
        int b = std::min(p3, p4);
        shit.push_back(input[id] - std::max(a, b));
        return {a, b};
    };

    fuck(fuck, 0, n);
    // for (int i = 0; i < n - 1; i++) {
    //     if (h_lca[i] != -1) {
    //         shit.push_back(h_lca[i] - std::max(input[lvs[i]], input[lvs[i + 1]]));
    //     }
    // }
    std::sort(shit.begin(), shit.end());
}

int max_towers(int ql, int qr, int d) {
    ::q++;
    qr++;

    // return 0;
    {
        int it = shit.end() - std::lower_bound(shit.begin(), shit.end(), d);
        return it + 1;
    }

    // #ifndef LOCAL
    //     if (q <= 1) {
    //         auto fuck = [&](auto fuck, int l, int r, int max) -> int {
    //             if (l >= r) {
    //                 return 0;
    //             }
    //             int res = st_min.get_min(l, r).first <= max ? 1 : 0;
    //             if (l + 1 < r) {
    //                 int id = st_max.get_min(l, r).second;
    //                 int res2 = 0;
    //                 res2 += fuck(fuck, l, id, input[id] - d);
    //                 res2 += fuck(fuck, id + 1, r, input[id] - d);
    //                 res = std::max(res, res2);
    //             }
    //             return res;
    //         };
    //         int res = fuck(fuck, ql, qr, 1.1e9);
    //         return res;
    //     }
    // #endif

    int it1 = std::lower_bound(lvs.begin(), lvs.end(), ql) - lvs.begin();
    int it2 = std::lower_bound(lvs.begin(), lvs.end(), qr) - lvs.begin();

    int res = 1;
    for (int i = it1; i + 1 < it2; i++) {
        res += std::max(input[lvs[i]], input[lvs[i + 1]]) + d <= h_lca[i];
    }
    return res;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 22ms
memory: 21088kb

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:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

wrong answer 3rd lines differ - expected: '1', found: '2'

Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 1ms
memory: 3312kb

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:

131

result:

wrong answer 3rd lines differ - expected: '13', found: '131'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #65:

score: 0
Wrong Answer
time: 47ms
memory: 29304kb

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:

33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
33010
...

result:

wrong answer 3rd lines differ - expected: '11903', found: '33010'

Subtask #5:

score: 17
Accepted

Test #86:

score: 17
Accepted
time: 11ms
memory: 8568kb

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:

7197
7063
150
5030
5227
7333
1778
6675
2012
5921
4878
7477
4598
2769
5360
6465
7660
7234
7794
2760
6321
7056
7302
4749
464
2029
5650
1973
6227
4900
4966
4990
3142
785
5818
3005
7705
6967
1940
5880
7201
4752
1278
6554
2951
894
6601
7019
7236
6076
5182
6579
2343
2070
4337
5744
4437
2262
6686
1739
7756...

result:

ok 31567 lines

Test #87:

score: 0
Accepted
time: 55ms
memory: 29732kb

input:

100000
187962236 252322706 659740540 756184857 615615021 870954164 997894181 924184575 178246679 206117936 948374169 611376809 940125697 583402158 621243496 179806768 420420048 261580744 495350370 179501503 624736464 865025098 132756697 396891347 254854635 384499314 232013282 699329403 718265326 972...

output:

21501
24099
33073
16936
24145
8440
674
23350
29618
2899
7659
19499
19027
10215
4083
14518
30601
23009
17970
7096
15472
32634
26673
29553
6232
11457
690
8753
7786
4078
28404
25386
28535
1752
5912
16456
18098
25382
30618
28242
30215
30920
19228
20981
27023
18696
16047
19091
7953
9832
13542
4224
26991
...

result:

ok 100002 lines

Test #88:

score: 0
Accepted
time: 47ms
memory: 29776kb

input:

100000
195876641 146621733 341834495 380796725 369334549 293410542 978028075 874593626 703011075 519634832 164249958 637129162 298077642 409700388 597488029 208278772 746990129 51413696 131278404 949003744 715997226 208017329 494082201 972593011 718736913 14104256 281109734 780778410 380464107 29853...

output:

31327
32678
5845
12353
3257
8926
13111
9562
10067
19324
255
7803
6244
5462
17193
33299
5823
24299
31456
20379
13299
17670
10250
31047
750
28337
5058
5037
31225
2578
18079
32308
15960
21734
23722
17448
3403
22865
12869
22981
12521
27550
32677
8772
16024
27145
32107
20420
31630
25199
583
30494
13145
2...

result:

ok 100002 lines

Test #89:

score: 0
Accepted
time: 75ms
memory: 29268kb

input:

100000
140151127 703171223 64650609 807179656 91579199 616439566 262279532 635385641 182204773 746966272 29134735 694384584 151383885 835424004 374370699 839210095 26199233 802967114 424348660 929961627 334908843 613933030 264472963 967927306 374534013 795616963 181399017 942772713 325557168 6356971...

output:

16852
44989
5073
188
18334
719
37773
31991
27369
49758
2886
37462
2269
14671
36297
47833
45768
45948
44197
36763
13579
37257
34232
22326
19121
4483
3193
9572
44327
43476
37410
4641
9134
21884
17460
39750
31826
13138
6713
29509
28834
48569
47845
14636
42288
209
9318
7431
45730
16465
5906
40699
39638
...

result:

ok 100002 lines

Test #90:

score: 0
Accepted
time: 38ms
memory: 29180kb

input:

100000
229371426 615845385 8395463 725670138 253945139 837481603 267122821 564928938 88384991 615119435 233045729 736737408 9623699 705904592 292693606 920163778 297466268 725313668 361252589 813252985 350864743 741659990 170849476 539562600 432839207 511464025 99353592 875179636 297454089 687124695...

output:

17581
24948
38391
14419
27799
4569
38668
35697
26067
49978
42190
1235
1655
28211
22625
47715
40160
39008
37550
19341
5003
109
10527
40699
48346
4305
5676
8370
23348
27672
31587
48842
49999
46869
20992
43858
6386
35113
50
46394
49096
24013
33036
49696
44127
30556
26524
3723
36254
9349
12089
2510
3087...

result:

ok 100002 lines

Test #91:

score: 0
Accepted
time: 43ms
memory: 29164kb

input:

100000
487111066 855860485 99041551 892763368 90402565 506637676 222215611 835773505 321823015 869201207 89953137 536799062 104579533 834586895 472040129 763002761 152483347 634595719 449887741 956583186 34700464 521025155 55345113 944384213 127641496 513194723 356649230 967880428 337980827 91463839...

output:

942
45725
29253
32000
34983
3056
10934
34915
6732
11677
1908
652
47087
1198
27913
18121
7533
3821
24817
31833
5715
2456
36255
41755
48827
46825
46456
9695
562
7920
24435
19004
5205
24363
3456
48946
23953
49466
31719
39841
12272
16871
42212
19612
38959
9101
5563
12587
43949
48475
41360
6428
41967
184...

result:

ok 100002 lines

Test #92:

score: 0
Accepted
time: 46ms
memory: 29124kb

input:

100000
27073748 576331364 400237255 795460519 71014022 637435072 214575137 823870913 216504420 807569134 433278403 608674530 363485760 723516242 157786468 990284424 191375275 730792204 290439949 971661182 370244883 986406055 345467763 738556373 233197961 953353962 129769517 642436238 381534949 97463...

output:

15228
45987
5889
540
24979
14594
39331
30269
9981
22404
3267
11420
12707
42431
49834
35779
22037
20640
28981
41713
13306
2152
44699
25014
49999
49722
28703
25852
31644
27995
42377
43981
46325
34863
25315
25298
48064
12187
614
35850
45155
47254
21988
7289
5643
47552
48834
14785
10748
44858
26283
2402...

result:

ok 100002 lines

Test #93:

score: 0
Accepted
time: 53ms
memory: 36128kb

input:

100000
14044 31568 48921 51214 59358 71379 100023 115598 139483 155653 157116 163984 169449 181325 188904 191112 194401 200495 208085 244825 258317 269389 271415 278442 294904 302861 331145 358689 365346 371514 371674 420312 426358 426926 439486 447109 449034 452747 459208 464379 471543 477242 48520...

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:

ok 100002 lines

Test #94:

score: 0
Accepted
time: 57ms
memory: 36044kb

input:

100000
999997134 999971880 999971447 999963682 999958496 999954233 999941005 999934956 999913043 999912124 999899751 999895915 999889723 999865869 999850495 999849430 999843930 999825051 999812617 999790616 999785641 999771255 999768902 999766470 999753769 999744896 999726315 999707943 999707638 999...

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:

ok 100002 lines

Test #95:

score: 0
Accepted
time: 59ms
memory: 33396kb

input:

100000
10308 12726 14970 29067 32105 43123 49977 68697 88015 88028 126474 130169 135685 137521 160062 169353 177310 194965 211656 230278 234919 235394 248590 252495 255260 261674 277375 302750 310249 323236 330372 331411 353695 359830 374529 382948 412643 433170 449860 454473 473256 476229 477424 48...

output:

5
3
5
5
1
5
1
2
1
3
3
5
3
5
5
5
5
2
3
5
5
1
5
1
1
2
3
5
5
2
2
5
5
1
1
4
1
1
1
5
5
1
1
1
1
5
5
3
5
5
1
1
3
5
3
5
5
3
4
4
5
1
2
3
1
4
5
3
5
3
5
5
1
4
2
3
5
5
1
3
1
3
5
5
4
1
5
2
5
1
1
3
5
5
1
3
1
5
5
5
5
3
5
1
5
2
1
4
5
4
1
5
4
1
5
3
2
5
1
5
2
5
5
2
5
1
2
5
1
3
5
2
3
1
4
1
3
5
4
4
1
2
5
3
5
3
2
5
1
1
...

result:

ok 100002 lines

Test #96:

score: 0
Accepted
time: 49ms
memory: 33920kb

input:

100000
999999375 999993451 999991946 999986204 999984712 999978443 999965310 999963490 999950472 999950215 999935622 999934052 999920801 999884366 999878792 999871703 999841904 999839499 999835391 999831297 999828717 999815901 999773795 999769518 999747787 999736911 999729803 999726952 999716990 999...

output:

3
1
3
5
3
3
1
4
5
3
3
3
3
1
3
3
3
3
1
4
1
1
3
3
1
2
4
1
3
3
1
3
3
2
4
3
1
3
3
2
2
3
3
3
3
1
5
3
3
5
1
3
1
3
3
3
4
3
3
5
3
3
4
3
1
3
3
3
5
3
3
5
5
3
5
3
2
3
5
3
5
5
3
4
3
3
5
3
3
3
3
3
5
3
1
3
3
1
3
3
3
3
3
5
3
4
3
4
3
1
3
1
3
5
3
5
3
3
1
3
2
3
3
5
3
3
4
4
3
3
3
3
5
3
4
3
1
3
1
3
3
1
1
3
5
3
3
3
3
3
...

result:

ok 100002 lines

Subtask #6:

score: 0
Wrong Answer

Test #97:

score: 0
Wrong Answer
time: 49ms
memory: 26132kb

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:

25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
25889
...

result:

wrong answer 3rd lines differ - expected: '7293', found: '25889'

Subtask #7:

score: 0
Skipped

Dependency #1:

0%