QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#96736 | #5555. Chaotic Construction | _b_ | WA | 1ms | 3372kb | C++14 | 973b | 2023-04-15 14:41:49 | 2023-04-15 14:41:50 |
Judging History
answer
#include<iostream>
#include<set>
#include<string>
using namespace std;
int n, q;
int main() {
cin >> n >> q;
string flag; int pos1, pos2; set<int>tree;
for (int i = 0; i < q; i++) {
cin >> flag;
if (flag == "-") {
cin >> pos1;
tree.insert(pos1);
}
else if (flag == "+") {
cin >> pos1;
tree.erase(pos1);
}
else {
cin >> pos1 >> pos2;
if (pos1 > pos2) {
int tmp = pos1;
pos1 = pos2;
pos2 = tmp;
}
if (tree.size() == 0) {
cout << "possible" << endl;
}
else {
set<int>::iterator iters = tree.lower_bound(pos2);
set<int>::iterator iters_1 = --iters; ++iters;
set<int>::iterator iters_2 = tree.lower_bound(pos1);
if ((iters != tree.end() || (iters_2 != tree.end() && *iters_2 == pos1) || iters_2 != tree.begin()) && (iters != tree.begin() && *iters_1 >= pos1))
cout << "impossible" << endl;
else
cout << "possible" << endl;
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3372kb
input:
10 12 ? 1 5 - 2 - 8 ? 9 2 ? 9 8 ? 9 7 ? 6 7 ? 3 7 ? 1 9 ? 9 1 + 8 ? 10 3
output:
possible impossible impossible impossible possible possible possible possible possible
result:
ok 9 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3332kb
input:
20 20 ? 17 4 - 11 + 11 ? 16 1 - 8 - 13 ? 18 12 ? 17 11 ? 9 16 + 8 ? 18 4 ? 8 4 - 20 - 14 ? 7 12 ? 19 20 ? 6 10 + 13 ? 5 11 + 20
output:
possible possible impossible impossible impossible possible possible possible possible possible impossible
result:
wrong answer 9th lines differ - expected: 'impossible', found: 'possible'