답안 #1003844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003844 2024-06-20T18:54:14 Z vjudge1 Zagrade (COI20_zagrade) C++17
0 / 100
555 ms 1112 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
const int maxn = 5e5+10;
const int inf = 1e18+10;
int n;
int query(int l, int r) {
	if(l > r) return 0;
	if(l < 0 or r >= n) return 0;
	cout << "? " << l+1 << " " << r+1 << endl;
	cout.flush(); 
	int x; cin >> x;
	return x;
}

int32_t main() {
	// #ifndef ONLINE_JUDGE
	// freopen("in.in","r",stdin);
	// freopen("out.out","w",stdout);
	// #endif

	int q;
	cin >> n >> q;
	vector<int> ans(n,0);
	int antok = -inf;
	int pos = 0;
	int qtd = n/2;
	while(pos+1 < n) {
		int l = pos+1;
		int r = pos;
		while(l-1 > antok && query(l-1,r+1)) {
			l--;
			r++;
			ans[l] = +1;
			ans[r] = -1;
			qtd--;
		}
		if(l <= r) antok = r;
		pos = r+1;
	}

	for(int i = 0; i < n; i++) {
		if(ans[i] == 0) {
			if(qtd == 0) {
				ans[i] = +1;
			}
			else {
				qtd--;
				ans[i] = -1;
			}
		}
	}

	cout << "! ";
	for(int i = 0; i < n; i++) {
		if(ans[i] == -1) cout << ')';
		else cout << '(';
	}
	cout.flush();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Incorrect 4 ms 344 KB Mismatch at position 1. Expected (, found )
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
3 Incorrect 6 ms 344 KB Mismatch at position 30. Expected (, found )
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 279 ms 1112 KB Output is correct
3 Incorrect 517 ms 1112 KB Mismatch at position 1. Expected (, found )
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 555 ms 1112 KB Output is correct
3 Incorrect 455 ms 1112 KB Mismatch at position 11. Expected (, found )
4 Halted 0 ms 0 KB -