답안 #583138

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
583138 2022-06-24T21:57:32 Z Markomafko972 Zagrade (COI20_zagrade) C++14
100 / 100
860 ms 1016 KB
#include <bits/stdc++.h>
using namespace std;

int n, q, odg;
stack<int> s;
char sol[100005];

int main () {
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> q;
	for (int i = 1; i <= n; i++) {
		if (s.size() == 0) {
			s.push(i);
			continue;
		}
		
		cout << "? " << s.top() << " " << i << endl;
		cin >> odg;
		if (odg == 0) {
			s.push(i);
		}
		else {
			sol[s.top()] = '(';
			sol[i] = ')';
			s.pop();
		}
	}
	
	int kol = (int)s.size()/2;
	while ((int)s.size() > kol) {
		sol[s.top()] = '(';
		s.pop();
	}
	while ((int)s.size() > 0) {
		sol[s.top()] = ')';
		s.pop();
	}
	
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << sol[i];
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 9 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 8 ms 324 KB Output is correct
8 Correct 6 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 10 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 4 ms 332 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
8 Correct 9 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 420 ms 708 KB Output is correct
3 Correct 829 ms 596 KB Output is correct
4 Correct 650 ms 496 KB Output is correct
5 Correct 819 ms 508 KB Output is correct
6 Correct 799 ms 576 KB Output is correct
7 Correct 860 ms 656 KB Output is correct
8 Correct 812 ms 732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 494 ms 1016 KB Output is correct
3 Correct 473 ms 648 KB Output is correct
4 Correct 833 ms 632 KB Output is correct
5 Correct 804 ms 632 KB Output is correct
6 Correct 749 ms 664 KB Output is correct
7 Correct 703 ms 740 KB Output is correct
8 Correct 713 ms 572 KB Output is correct