QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#410656#6733. Moniphant Sleepundefined-uxWA 1ms3644kbC++141.9kb2024-05-14 10:53:402024-05-14 10:53:40

Judging History

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

  • [2024-05-14 10:53:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3644kb
  • [2024-05-14 10:53:40]
  • 提交

answer

#include <iostream>
#include <vector>
#include <set>

using namespace std;

class MoniphantSleep {
private:
    vector<int> levels;
    vector<set<int>> angry_levels;
    set<int> global_angry;
    int n;

public:
    MoniphantSleep(int n) : n(n) {
        levels.resize(n + 1, 500000);
        angry_levels.resize(n + 1);
    }

    void sleep(int l, int r) {
        for (int i = l; i <= r; ++i) {
            ++levels[i];
        }
    }

    void wake_up(int l, int r) {
        for (int i = l; i <= r; ++i) {
            --levels[i];
        }
    }

    void insult(int l, int r) {
        for (int i = l; i <= r; ++i) {
            angry_levels[i].insert(levels[i]);
            global_angry.insert(levels[i]);
        }
    }

    void retaliate(int l, int r) {
        if (global_angry.empty()) return;

        int min_angry_level = *global_angry.begin();
        for (int i = l; i <= r; ++i) {
            while (levels[i] > min_angry_level && angry_levels[i].count(levels[i])) {
                angry_levels[i].erase(levels[i]);
                levels[i] = min_angry_level;
            }
        }

        // Remove the minimum angry level from the global set if it's no longer angry for any Moniphant
        global_angry.erase(min_angry_level);
    }

    int query(int idx) {
        return levels[idx];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q;
    cin >> n >> q;

    MoniphantSleep ms(n);

    for (int i = 0; i < q; ++i) {
        int op, l, r;
        cin >> op >> l >> r;

        if (op == 1) {
            ms.sleep(l, r);
        } else if (op == 2) {
            ms.wake_up(l, r);
        } else if (op == 3) {
            ms.insult(l, r);
        } else if (op == 4) {
            ms.retaliate(l, r);
        } else if (op == 5) {
            cout << ms.query(l) << "\n";
        }
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3640kb

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:

500004

result:

ok 1 number(s): "500004"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3644kb

input:

3 7
2 1 3
3 1 3
1 1 3
1 1 3
5 1 1
4 1 3
5 1 1

output:

500001
500001

result:

wrong answer 2nd numbers differ - expected: '499999', found: '500001'