QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#526828#4563. Radio Towersarbuzick#0 54ms9900kbC++201.8kb2024-08-21 21:33:042024-08-21 21:33:04

Judging History

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

  • [2024-08-21 21:33:04]
  • 评测
  • 测评结果:0
  • 用时:54ms
  • 内存:9900kb
  • [2024-08-21 21:33:04]
  • 提交

answer

#include "towers.h"

#include <bits/stdc++.h>

using namespace std;

constexpr int inf = 1e9 + 7;

constexpr int R = 1 << 17;

pair<int, int> mn[R * 2], mx[R * 2];

void build() {
    for (int i = R - 1; i > 0; --i) {
        mn[i] = min(mn[i * 2], mn[i * 2 + 1]);
        mx[i] = max(mx[i * 2], mx[i * 2 + 1]);
    }
}

pair<int, int> get_mn(int l, int r) {
    l += R;
    r += R;
    pair<int, int> ans(inf, -1);
    while (l < r) {
        if (l & 1) {
            ans = min(ans, mn[l++]);
        }
        if (r & 1) {
            ans = min(ans, mn[--r]);
        }
        l >>= 1;
        r >>= 1;
    }
    return ans;
}

pair<int, int> get_mx(int l, int r) {
    l += R;
    r += R;
    pair<int, int> ans(-inf, -1);
    while (l < r) {
        if (l & 1) {
            ans = max(ans, mx[l++]);
        }
        if (r & 1) {
            ans = max(ans, mx[--r]);
        }
        l >>= 1;
        r >>= 1;
    }
    return ans;
}

int prv[R], ll[R], rr[R];

void build_tree(int l, int r, int pr) {
    if (l == r) {
        return;
    }
    int m = get_mx(l, r).second;
    prv[m] = pr;
    ll[m] = l;
    rr[m] = r;
    build_tree(l, m, m);
    build_tree(m + 1, r, m);
}

int pr_sum[R];

void init(int n, vector<int> h) {
    for (int i = 0; i < n; ++i) {
        mn[i + R] = mx[i + R] = make_pair(h[i], i);
    }
    build();
    build_tree(0, n, -1);
    for (int i = 0; i < n; ++i) {
        pr_sum[i + 1] = pr_sum[i];
        if (rr[i] == ll[i] + 1) {
            pr_sum[i + 1]++;
        }
    }
}

int max_towers(int l, int r, int d) {
    r++;
    int ans = pr_sum[r] - pr_sum[l];
    if (rr[l] != ll[l] + 1 && rr[l] == l + 1) {
        ans++;
    }
    if (r - 1 != l && rr[r - 1] != ll[r - 1] + 1 && ll[r - 1] == r - 1) {
        ans++;
    }
    return ans;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 24ms
memory: 9836kb

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

result:

wrong answer 4th lines differ - expected: '1', found: '2'

Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 0ms
memory: 8160kb

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:

16

result:

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

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #65:

score: 14
Accepted
time: 33ms
memory: 9560kb

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
4770
14278
13956
571
9308
4389
9
22097
16784
26037
2813
8487
16602
2029
6158
17236
29707
19863
12083
20816
18090
4195
11612
4623
6658
7660
624
9839
13012
14475
11799
14795
6365
7308
5981
13614
14208
15922
17325
6020
10291
1819
29076
3117
6638
5810
28747
14944
9541
5498
1015
5001
20938
305
1993...

result:

ok 76385 lines

Test #66:

score: 0
Wrong Answer
time: 52ms
memory: 9900kb

input:

100000
646527498 970130195 879656883 854139882 920539450 14492099 70829155 825526447 519236533 385324961 763550841 616593724 202907362 504717767 861551686 907280958 806537098 75704450 554965405 422432432 940208667 752899470 775720977 966726690 961764576 993069149 823583546 69522676 360505418 7633091...

output:

14639
9186
584
818
3164
16444
1579
16458
6571
5493
20925
3038
3459
7677
14998
8753
2530
12026
13859
985
3177
296
398
6246
6210
6153
7709
24258
1152
3748
7952
8080
13438
5107
1161
4986
23542
15941
18037
791
15601
8274
3031
13339
8920
8559
11180
24013
394
8673
4017
6704
6973
210
2085
8072
3422
6896
10...

result:

wrong answer 72021st lines differ - expected: '1', found: '0'

Subtask #5:

score: 0
Wrong Answer

Test #86:

score: 0
Wrong Answer
time: 9ms
memory: 8508kb

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:

8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
8004
...

result:

wrong answer 3rd lines differ - expected: '7197', found: '8004'

Subtask #6:

score: 0
Wrong Answer

Test #97:

score: 0
Wrong Answer
time: 54ms
memory: 9276kb

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:

8349
21427
5662
21827
26907
2291
23916
10524
24336
18016
129
13455
9770
21976
10777
10481
6181
23042
1919
4552
25920
6777
20509
14798
6559
14190
24784
18071
733
6200
19472
8746
7040
2033
7226
713
876
3519
10084
13229
8251
3019
18152
2596
2309
11129
27487
5329
10158
5747
2767
23134
9529
16660
18864
7...

result:

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

Subtask #7:

score: 0
Skipped

Dependency #1:

0%