QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#410656 | #6733. Moniphant Sleep | undefined-ux | WA | 1ms | 3644kb | C++14 | 1.9kb | 2024-05-14 10:53:40 | 2024-05-14 10:53:40 |
Judging History
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;
}
詳細信息
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'