답안 #1111849

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111849 2024-11-13T06:57:21 Z LM1 Zagrade (COI20_zagrade) C++14
100 / 100
1934 ms 1592 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
int main(){
	ios_base::sync_with_stdio(NULL);cin.tie(NULL);
	int n,q,ok;cin>>n>>q;
	char ans[n+1];
	stack<int>st;
	for(int i=1;i<=n;i++){
		if(st.size()==0){
			st.push(i);
			continue;
		}
		cout<<"? "<<st.top()<<" "<<i<<endl;
		cin>>ok;
		if(ok){
			ans[st.top()]='(';
			ans[i]=')';
			st.pop();
		}
		else{
			st.push(i);
		}
	}
	int n1=st.size();
	for(int i=0;i<n1/2;i++){
		ans[st.top()]='(';
		st.pop();
	}
	while(st.size()){
		ans[st.top()]=')';
		st.pop();
	}
	cout<<"! ";
	for(int i=1;i<=n;i++)cout<<ans[i];
	cout<<endl;
}
/*
((()))
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 9 ms 336 KB Output is correct
3 Correct 13 ms 336 KB Output is correct
4 Correct 18 ms 336 KB Output is correct
5 Correct 16 ms 336 KB Output is correct
6 Correct 18 ms 336 KB Output is correct
7 Correct 17 ms 336 KB Output is correct
8 Correct 12 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 15 ms 336 KB Output is correct
3 Correct 16 ms 336 KB Output is correct
4 Correct 14 ms 448 KB Output is correct
5 Correct 15 ms 336 KB Output is correct
6 Correct 16 ms 336 KB Output is correct
7 Correct 16 ms 336 KB Output is correct
8 Correct 14 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 915 ms 540 KB Output is correct
3 Correct 1906 ms 536 KB Output is correct
4 Correct 1884 ms 536 KB Output is correct
5 Correct 1856 ms 536 KB Output is correct
6 Correct 1850 ms 540 KB Output is correct
7 Correct 1817 ms 1452 KB Output is correct
8 Correct 1864 ms 540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1901 ms 1592 KB Output is correct
3 Correct 1875 ms 1356 KB Output is correct
4 Correct 1781 ms 1424 KB Output is correct
5 Correct 1934 ms 1112 KB Output is correct
6 Correct 1806 ms 1208 KB Output is correct
7 Correct 1892 ms 916 KB Output is correct
8 Correct 1788 ms 536 KB Output is correct