QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#780040#2813. Weirdtreelinusvdv#0 96ms23652kbC++142.5kb2024-11-24 23:56:342024-11-24 23:56:35

Judging History

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

  • [2024-11-24 23:56:35]
  • 评测
  • 测评结果:0
  • 用时:96ms
  • 内存:23652kb
  • [2024-11-24 23:56:34]
  • 提交

answer

#include "weirdtree.h"
#include <bit>
#include <cstdint>
#include <iostream>
#include <vector>


struct Node {
    int64_t value = 0;
    int64_t max = 0;
};
std::vector<Node> segtree;

Node Merge(Node first, Node second) {
    return {first.value + second.value, std::max(first.max, second.max)};
}
int num;


Node Insert(int left, int right, int index, int value, int value_index) {
    if (value_index < left || value_index >= right) {
        return segtree[index];
    }
    if (left + 1 == right) {
        segtree[index] = {value, value};
        return segtree[index];
    }
    int middle = (left + right) / 2;
    segtree[index] = Merge(Insert(left, middle, index*2+1, value, value_index),
                           Insert(middle, right, index*2+2, value, value_index));
    return segtree[index];
}


Node Query(int left, int right, int index, int query_left, int query_right) {
    if (query_right <= left || right <= query_left) {
        return {};
    }
    if (query_left <= left && right <= query_right) {
        return segtree[index];
    }
    int middle = (left + right) / 2;
    return Merge(Query(left, middle, index*2+1, query_left, query_right),
                 Query(middle, right, index*2+2, query_left, query_right));
}


// value, index
std::pair<int64_t, int64_t> GetMax (int left, int right, int index, int query_left, int query_right) {
    if (query_right <= left || right <= query_left) {
        return {-1, -1};
    }
    if (left + 1 == right) {
        return {segtree[index].value, left};
    }
    int middle = (left + right) / 2;
    if (query_right <= left || middle <= query_left) {
        return GetMax(middle, right, index*2+2, query_left, query_right);
    }
    if (query_right <= middle || right <= query_left) {
        return GetMax(left, middle, index*2+1, query_left, query_right);
    }
    if (segtree[index*2+1].max >= segtree[index*2+2].max) {
        return GetMax(left, middle, index*2+1, query_left, query_right);
    }
    return GetMax(middle, right, index*2+2, query_left, query_right);
}


void initialise(int N, int Q, int h[]) {
    segtree = std::vector<Node>(N*4);
    for (int i = 0; i < N; i++) {
        Insert(0, N, 0, h[i+1], i);
    }
    num = N;
}


void cut(int l, int r, int k) {
    for (int i = 0; i < k; i++) {
        std::pair<int64_t, int64_t> get_max = GetMax(0, num, 0, l-1, r);
        Insert(0, num, 0, get_max.first-1, get_max.second);
    }
}


void magic(int i, int x) {
    Insert(0, num, 0, x, i-1);
}


long long int inspect(int l, int r) {
    return Query(0, num, 0, l-1, r).value;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

966 1000
188363740 589476690 819684757 475179567 162289921 733331939 680003760 423847214 703730312 291752235 351463201 937522268 64588573 399012809 272561165 599780539 83270822 164102043 624995073 120374612 678210514 488108346 941579981 767236037 850406512 515467244 934426708 262361378 733612602 464...

output:

Unauthorized output

result:

wrong answer 1st lines differ - expected: '99386228771', found: 'Unauthorized output'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded

input:

937 1000
631216009 869613152 930472391 565464603 615860285 225788550 621532305 671044759 686011029 102483970 507799388 976017264 586239272 91471532 773404833 981261100 664781538 691746892 973047425 562711051 792865846 686480962 800771605 626015452 783329411 478894142 826983440 279108379 994766235 23...

output:

Unauthorized output

result:


Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 96ms
memory: 23652kb

input:

279629 300000
864485544 147664426 873456004 602824795 902744016 20056943 260905686 609162276 241739883 338354289 437560714 444081255 584613844 200551305 963158452 282143442 169245526 10832409 265203076 576549337 275863148 94296798 887754059 15388512 25015579 800125936 979301246 68177101 30414420 446...

output:

Unauthorized output

result:

wrong answer 1st lines differ - expected: '139687223836955', found: 'Unauthorized output'

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%