Submission #1004217

# Submission time Handle Problem Language Result Execution time Memory
1004217 2024-06-21T06:31:03 Z vjudge1 Zagrade (COI20_zagrade) C++17
0 / 100
538 ms 3736 KB
#include <bits/stdc++.h>

using namespace std;

const int M = 1e5 + 1;

char ans[M];

bool que(int x,int y)
{
	cout<<"? "<<x<<' '<<y<<endl;
	bool b;
	cin>>b;
	return b;
}

void solve(int a,int b)
{
	if (a>=b)
		return;
	if (a+1==b)
	{
		ans[a]='(';
		ans[b]=')';
		return;
	}
	bool v=que(a+1,b-1);
	if (v)
	{
		ans[a]='(';
		ans[b]=')';
		solve(a+1,b-1);	
		return;
	}
	for (int i=b-2;i>a;i-=2)
	{
		v=que(a,i);
		if (v)
		{
			ans[i+1]='(';
			ans[b]=')';
			solve(a,i);
			solve(i+1,b-1);
			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 Correct 4 ms 444 KB Output is correct
3 Incorrect 3 ms 344 KB Mismatch at position 13. Expected (, found
4 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 Correct 538 ms 3736 KB Output is correct
3 Incorrect 519 ms 1188 KB Mismatch at position 20. Expected (, found
4 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 -