답안 #320896

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320896 2020-11-10T07:52:02 Z dolphingarlic Zagrade (COI20_zagrade) C++14
100 / 100
1244 ms 888 KB
#include <bits/stdc++.h>
using namespace std;

bool guess(int a, int b) {
	cout << "? " << a << ' ' << b << endl;
	bool res;
	cin >> res;
	return res;
}

char ans[100001];

int main() {
	int n, q, rem;
	cin >> n >> q;
	rem = n / 2;
	stack<int> stck;
	for (int i = 1; i <= n; i++) {
		if (!stck.size()) stck.push(i);
		else if (guess(stck.top(), i)) {
			ans[stck.top()] = '(';
			ans[i] = ')';
			stck.pop();
			rem--;
		} else stck.push(i);
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) {
		if (ans[i] == '(' || ans[i] == ')') cout << ans[i];
		else if (rem) {
			cout << ')';
			rem--;
		} else cout << '(';
	}
	cout << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 7 ms 364 KB Output is correct
3 Correct 12 ms 364 KB Output is correct
4 Correct 7 ms 364 KB Output is correct
5 Correct 10 ms 364 KB Output is correct
6 Correct 10 ms 364 KB Output is correct
7 Correct 10 ms 364 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 9 ms 364 KB Output is correct
3 Correct 11 ms 364 KB Output is correct
4 Correct 13 ms 364 KB Output is correct
5 Correct 9 ms 364 KB Output is correct
6 Correct 8 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
8 Correct 9 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 502 ms 740 KB Output is correct
3 Correct 879 ms 744 KB Output is correct
4 Correct 801 ms 620 KB Output is correct
5 Correct 923 ms 676 KB Output is correct
6 Correct 1244 ms 484 KB Output is correct
7 Correct 885 ms 828 KB Output is correct
8 Correct 865 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 836 ms 888 KB Output is correct
3 Correct 846 ms 684 KB Output is correct
4 Correct 791 ms 628 KB Output is correct
5 Correct 895 ms 720 KB Output is correct
6 Correct 1012 ms 740 KB Output is correct
7 Correct 753 ms 772 KB Output is correct
8 Correct 814 ms 508 KB Output is correct