답안 #917596

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
917596 2024-01-28T13:07:50 Z PotatoMan Zagrade (COI20_zagrade) C++14
100 / 100
512 ms 1948 KB
#include <bits/stdc++.h>
#define inf INT_MAX
#define longlonginf LONG_LONG_MAX
#define mod 998244353
#define MAXN 200005
#define pii pair<ll,ll>
#define ll long long
#define deb(x) cerr<<"[ "<<#x<<" = "<<x<<" ]";
#define yes() cout<<"YES\n";
#define no() cout<<"NO\n";
using namespace std;
 
ll n,k,m,q,cur,z;
ll ans = 0;
string subtask;

void solve(){
	cin>>n>>q;
	ll rem = n/2;
	stack<int> s;
	string res = string(n,'.');
	for(int i = 1 ; i <= n ; i++){
		if( s.empty() ) {
			s.push(i);
			continue;
		}
		cout<<"? "<<s.top()<<" "<<i<<endl;
		cin>>k;
		if(k){
			res[s.top()-1] = '(';
			res[i-1] = ')';
			s.pop();
			rem--;
		}
		else{
			s.push(i);
		}
	}
	for(int i = 0 ; i < rem ; i++) {
		res[s.top()-1] =  '(';
		s.pop();
	}
	for(int i = 0 ; i < rem ; i++) {
		res[s.top()-1] =  ')';
		s.pop();
	}
	cout<<"! "<<res<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int T = 1;
	//cin>>T;
	for(int i = 0 ; i < T ; i++){
		//cout<<"Case #"<<i+1<<": ";
		solve();
	}
	return 0;
}
 
/*
	out of bound for loop
	(constraint change in loop)
	forget to change bool to int
	misread -> missed subtask
	you thought u declared it huh?
	not i but x
	logical operator
	wrong example/proof
	thoroughly
	wrong variables
	thinking it wrong
	bruh just try some test case
	capitals ;-;
	wrong data structure lol
	count memory usement
	corner case
	oversized array
	orders
	statements
	size initializer
	while con
	map -> array
	wrong digits??
	swapped variables??
	check if theres any variabled
	that got declared twice
	find some pattern
	name collision
	constraints??!
	mod !!
	resets
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 4 ms 596 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 4 ms 600 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 210 ms 524 KB Output is correct
3 Correct 426 ms 528 KB Output is correct
4 Correct 438 ms 536 KB Output is correct
5 Correct 458 ms 732 KB Output is correct
6 Correct 512 ms 528 KB Output is correct
7 Correct 409 ms 1892 KB Output is correct
8 Correct 432 ms 732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 408 ms 1856 KB Output is correct
3 Correct 407 ms 840 KB Output is correct
4 Correct 422 ms 1948 KB Output is correct
5 Correct 417 ms 852 KB Output is correct
6 Correct 476 ms 1328 KB Output is correct
7 Correct 473 ms 1628 KB Output is correct
8 Correct 436 ms 532 KB Output is correct