QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#142238#4563. Radio TowersQwerty1232#0 1ms4180kbC++201.7kb2023-08-18 19:29:122024-07-04 01:47:54

Judging History

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

  • [2024-07-04 01:47:54]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:4180kb
  • [2023-08-18 19:29:12]
  • 提交

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] = vec;
        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());
    }
};

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

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

int max_towers(int ql, int qr, int d) {
    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;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

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
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
2
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:


Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 11
Accepted
time: 1ms
memory: 3928kb

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:

13

result:

ok 3 lines

Test #9:

score: 0
Accepted
time: 1ms
memory: 4164kb

input:

2000
510696791 617882876 373405425 518361747 407161508 435668375 559543221 465317236 38039460 717410075 714427583 977153243 679286738 23933545 750215417 37078782 973334934 244734879 243897181 603105656 981870220 85688930 807317304 901266308 225354691 737318933 824323690 365669439 111883771 153256479...

output:

292

result:

ok 3 lines

Test #10:

score: 0
Accepted
time: 1ms
memory: 4072kb

input:

2000
516351740 512181903 200723571 993230512 160881035 858124753 539677115 120758992 855511696 883443323 930303372 707938300 186981787 145199071 581235758 65550786 7197175 474759320 732341567 517832089 220614631 428681162 168642809 331743780 689236970 514407524 725936494 447118446 628858360 36946526...

output:

91

result:

ok 3 lines

Test #11:

score: 0
Accepted
time: 1ms
memory: 4104kb

input:

2000
9654673 812116916 373455422 816862897 353222263 785552601 262143032 654718863 361397545 763154940 79011466 983035671 46521930 654559175 371270845 610911343 19671952 831534324 157278884 850193672 83857278 600512673 91419235 820220378 19933790 959137813 447541847 957882585 47577396 981451791 2290...

output:

336

result:

ok 3 lines

Test #12:

score: -11
Wrong Answer
time: 1ms
memory: 4180kb

input:

2000
101597651 901337214 94865893 515541321 223422476 791229261 361846447 652989994 147299317 644867197 32737606 525776949 182468296 547470985 330848340 873710937 392296086 971753844 156102346 764082424 254318166 685488259 221310405 521552461 481853974 868664461 300437861 938093383 466194541 6653033...

output:

175

result:

wrong answer 3rd lines differ - expected: '176', found: '175'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Time Limit Exceeded

Test #65:

score: 0
Time Limit Exceeded

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:

11903
4769
14277
13956
571
9307
4388
9
22096
16784
26036
2813
8487
16601
2029
6157
17236
29707
19863
12083
20816
18090
4195
11612
4622
6657
7659
623
9838
13011
14474
11799
14794
6365
7308
5981
13614
14207
15922
17324
6020
10291
1819
29076
3117
6637
5810
28747
14944
9540
5497
1014
5001
20938
305
1993...

result:


Subtask #5:

score: 0
Time Limit Exceeded

Test #86:

score: 0
Time Limit Exceeded

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
1777
6675
2011
5921
4878
7477
4598
2768
5360
6465
7660
7234
7794
2759
6321
7056
7302
4749
464
2028
5650
1972
6227
4900
4966
4990
3141
785
5818
3004
7705
6967
1939
5880
7201
4752
1278
6554
2950
894
6601
7019
7236
6076
5182
6579
2342
2069
4337
5744
4437
2261
6686
1738
7756...

result:


Subtask #6:

score: 0
Time Limit Exceeded

Test #97:

score: 0
Time Limit Exceeded

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:

7293
18702
4922
19043
23488
1992
20886
9156
21248
15708
115
11736
8528
19157
9406
9138
5400
20113
1699
3992
22639
5925
17883
12913
5726
12378
21617
15763
646
5417
16982
7638
6139
1776
6288
619
765
3079
8805
11541
7217
2649
15834
2238
2024
9705
23983
4664
8898
5006
2391
20170
8341
14535
16454
6623
18...

result:


Subtask #7:

score: 0
Skipped

Dependency #1:

0%