QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#96736#5555. Chaotic Construction_b_WA 1ms3372kbC++14973b2023-04-15 14:41:492023-04-15 14:41:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-15 14:41:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3372kb
  • [2023-04-15 14:41:49]
  • 提交

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'