Submission #1112104

# Submission time Handle Problem Language Result Execution time Memory
1112104 2024-11-13T16:32:29 Z vako_p Zagrade (COI20_zagrade) C++14
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define pb push_back

const int mxN = 1e6 + 5;
ll n,a[mxN];
stack<ll> st;

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	ll cnt = n / 2; 
	st.push(1);
 	for(int i = 2; i <= n;){
 		ll l = st.top(); 
		cout << "? " << l << ' ' << i << endl;
		ll ans;
		cin >> ans;
		if(ans){
			a[l] = 1;
			a[i] = 2;
			cnt--;
		 	st.pop();
		}
		else st.push(i);
		if(st.empty()) st.push(++i);
		i++;
	}
	ll val = 2;
	for(int i = 1; i <= n; i++){
		if(!a[i]){
			cnt--;
			a[i] = val;
			if(cnt == 0) val = 1;
		}
		cout << ((a[i] == 1) ? ( '(' ) : ( ')' ));
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Incorrect query ()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Incorrect query ()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Incorrect query ())(
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Incorrect query ())(
2 Halted 0 ms 0 KB -