Submission #1004082

# Submission time Handle Problem Language Result Execution time Memory
1004082 2024-06-21T04:51:08 Z vjudge1 Zagrade (COI20_zagrade) C++17
0 / 100
2 ms 344 KB
#include <bits/stdc++.h>

using namespace std;

const int M = 1e5 + 1;

char ans[M];

void solve(int a,int b)
{
	if (a+1==b)
	{
		ans[a]='(';
		ans[b]=')';
		return;
	}
	cout<<"? "<<a+1<<' '<<b-1<<endl;
	bool v;
	cin>>v;
	if (v)
	{
		ans[a]='(';
		ans[b]=')';
		solve(a+1,b-1);	
		return;
	}
	for (int i=a+1;i<b;i+=2)
	{
		cout<<"? "<<a<<' '<<i<<endl;
		cin>>v;
		if (v)
		{
			int l=i-a+1;
			for (int j=0;j<l/2;j++)
			{
				ans[a+j]='(';
				ans[i-j]=')';
			}
			l=b-i;
			for (int j=0;j<l/2;j++)
			{
				ans[i+1+j]='(';
				ans[b-j]=')';
			}
			return;
		}
	}
}

int main()
{
	int n,q;
	cin>>n>>q;
	solve(1,n);
	cout<<"! ";
	for (int i=1;i<=n;i++)
		cout<<ans[i];
	cout<<endl;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB Mismatch at position 4. Expected ), found (
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 2 ms 344 KB Mismatch at position 4. Expected ), found (
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Mismatch at position 1. Expected ), found
2 Halted 0 ms 0 KB -