Submission #775669

# Submission time Handle Problem Language Result Execution time Memory
775669 2023-07-06T18:07:25 Z DangerNoodle7591 Zagrade (COI20_zagrade) C++17
100 / 100
829 ms 808 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 3 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 9 ms 320 KB Output is correct
8 Correct 8 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 3 ms 256 KB Output is correct
5 Correct 3 ms 208 KB Output is correct
6 Correct 9 ms 316 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
8 Correct 5 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 227 ms 396 KB Output is correct
3 Correct 650 ms 388 KB Output is correct
4 Correct 730 ms 392 KB Output is correct
5 Correct 558 ms 392 KB Output is correct
6 Correct 703 ms 388 KB Output is correct
7 Correct 694 ms 600 KB Output is correct
8 Correct 553 ms 392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 626 ms 808 KB Output is correct
3 Correct 594 ms 408 KB Output is correct
4 Correct 578 ms 660 KB Output is correct
5 Correct 587 ms 564 KB Output is correct
6 Correct 574 ms 592 KB Output is correct
7 Correct 829 ms 524 KB Output is correct
8 Correct 671 ms 388 KB Output is correct