답안 #1003900

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003900 2024-06-20T19:45:30 Z vjudge1 Zagrade (COI20_zagrade) C++17
0 / 100
602 ms 1960 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pii pair<int,int>
#define tii tuple<int,int,int,int,int>
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

bool ask(int l, int r){
	cout << "? " << l << " " << r << endl;
	int rt; cin >> rt;
	return rt;
}


signed main(){
	int n,q; cin >> n >> q;
	vector<bool> small(n+5,0);

	for(int i=1; i<n; i++){
		small[i] = ask(i,i+1);
	}

	vector<int> p(n+5,0), s(n+5,0);
	for(int i=1; i<=n; i++){
		p[i] = p[i-1]+1-small[i-1];
	}
	for(int i=n; i>0; i--){
		s[i] = s[i+1]+1-small[i];
	}

	int bp=-1;
	for(int i=1; i<n; i++){
		if(p[i]==s[i+1]){
			bp=i;
			break;
		}
	}

	assert(bp!=-1);
	cout << "! ";
	for(int i=1; i<=n; i++){
		if(small[i]) cout << "()", i++;
		else{
			if(i<=bp) cout << "(";
			else cout << ")";
		}
	}
	cout << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Incorrect 5 ms 440 KB Mismatch at position 10. Expected ), found (
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 567 ms 1956 KB Output is correct
3 Incorrect 602 ms 1960 KB Mismatch at position 16. Expected ), found (
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -