Submission #774315

# Submission time Handle Problem Language Result Execution time Memory
774315 2023-07-05T14:05:25 Z vjudge1 Zagrade (COI20_zagrade) C++17
100 / 100
783 ms 888 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define endl "\n"
#define ll long long
#define N 200005
#define pb push_back

int main(){
	lalala
	int n,q;cin>>n>>q;
	stack<int> s;
	char str[n+1];
	for(int i=1;i<=n;i++){
		if(s.size()){
			int a=s.top();
			cout<<"? "<<a<<" "<<i<<endl;
			int x;cin>>x;
			if(x==1){
				str[i]=')';
				str[a]='(';
				s.pop();
			}
			else{
				s.push(i);
			}
		}
		else{
			s.push(i);
		}
	}
	int m=s.size()/2;
	for(int i=0;i<m;i++){
		str[s.top()]='(';
		s.pop();
	}
	for(int i=0;i<m;i++){
		str[s.top()]=')';
		s.pop();
	}
	cout<<"! ";
	for(int i=1;i<=n;i++)cout<<str[i];
	cout<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 10 ms 208 KB Output is correct
4 Correct 9 ms 208 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
8 Correct 9 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
8 Correct 4 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 249 ms 388 KB Output is correct
3 Correct 754 ms 388 KB Output is correct
4 Correct 581 ms 392 KB Output is correct
5 Correct 547 ms 396 KB Output is correct
6 Correct 635 ms 388 KB Output is correct
7 Correct 577 ms 608 KB Output is correct
8 Correct 783 ms 392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 610 ms 888 KB Output is correct
3 Correct 751 ms 580 KB Output is correct
4 Correct 632 ms 600 KB Output is correct
5 Correct 634 ms 548 KB Output is correct
6 Correct 760 ms 620 KB Output is correct
7 Correct 597 ms 524 KB Output is correct
8 Correct 467 ms 388 KB Output is correct