QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#409350#6733. Moniphant Sleepundefined-ux#WA 1ms3720kbC++143.2kb2024-05-11 22:23:472024-05-11 22:23:48

Judging History

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

  • [2024-05-11 22:23:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3720kb
  • [2024-05-11 22:23:47]
  • 提交

answer

#include <bits/stdc++.h>
#define qio std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
#define lc (k << 1)
#define rc (k << 1 | 1)

using namespace std;
const int N = 5e5 + 20;
typedef pair<int, int> PII;


typedef struct {
    long long level, lazy; bool angry, clear;
    int l, r;
} Node;
Node BT[ N << 2];

int n, q, op, l, r;
void pushdown(int k) {
    if (BT[k].l == BT[k].r) return ;
    if (BT[k].angry && !BT[k].clear) {
        BT[k].angry = false;
        BT[lc].angry = true;
        BT[rc].angry = true;
    }
    else if (BT[k].clear) {
        BT[k].clear = false;
        BT[k].angry = false;
        BT[lc].angry = false;
        BT[rc].angry = false;
        BT[lc].clear = true;
        BT[rc].clear = true;
        BT[k].level = 5e5;
        BT[lc].level = 5e5;
        BT[rc].level = 5e5;
        BT[k].lazy = 0;
        BT[lc].lazy = 0;
        BT[rc].lazy = 0;
    }
    else if (BT[k].lazy) {
        BT[lc].lazy += BT[k].lazy;
        BT[rc].lazy += BT[k].lazy;
        BT[lc].level += BT[k].lazy;
        BT[rc].level += BT[k].lazy;
        BT[lc].angry = BT[k].angry;
        BT[rc].angry = BT[k].angry;
    }
}



void build(int k, int l, int r) {
    BT[k].l = l, BT[k].r = r;
    if (l == r) {
        BT[k].level = 5e5;
        return ;
    }

    build(lc, l, (r + l) >> 1);
    build(rc, (l + r) >> 1 | 1, r);
}


int query(int k, int idx) {
    if(BT[k].l > idx || BT[k].r < idx) return -1;
    if (BT[k].l == idx && BT[k].r == idx) return BT[k].level;

    pushdown(k);

    int left = query(lc, idx);
    return left == -1 ? query(rc, idx) : left;
}

void sleep(int k, int l, int r) {
    if(BT[k].l > r || BT[k].r < l) return ;
    if(BT[k].l >= l && BT[k].r <= r) {
        BT[k].lazy ++; BT[k].level ++;
        return ;
    }

    pushdown(k);
    sleep(lc, l, r); sleep(rc, l, r);
}

void awake(int k, int l, int r) {
    if(BT[k].l > r || BT[k].r < l) return ;
    if(BT[k].l >= l && BT[k].r <= r) {
        BT[k].lazy --; BT[k].level --;
        return ;
    }

    pushdown(k);
    awake(lc, l, r); awake(rc, l, r);
}



void angry(int k, int l, int r) {
    if(BT[k].l > r || BT[k].r < l) return ;
    if(BT[k].l >= l && BT[k].r <= r) {
        BT[k].angry = true;
        return ;
    }

    pushdown(k);
    angry(lc, l, r); angry(rc, l, r);
}

void fuck(int k, int l, int r) {
    if(BT[k].l > r || BT[k].r < l) return ;
    if(BT[k].l >= l && BT[k].r <= r) {
        BT[k].level = 5e5; BT[k].clear = true;
        return ;
    }

    pushdown(k);
    fuck(lc, l, r); fuck(rc, l, r);
}



int main() { qio
    cin >> n >> q;
    build(1, 1, n);
    while(q--) {
        cin >> op >> l >> r;
        switch (op) {
            case 1:
                sleep(1, l, r);
                break;
            case 2:
                awake(1, l , r);
                break;
            case 3:
                angry(1, l, r);
                break;
            case 4:
                fuck(1, l, r);
                break;
            case 5:
                cout << query(1, l) << endl;
                break;
        }
    }



    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 9
1 1 1
1 1 1
1 1 1
3 1 1
2 1 1
1 1 1
1 1 1
4 1 1
5 1 1

output:

500000

result:

wrong answer 1st numbers differ - expected: '500004', found: '500000'