| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1152629 | zhehan | Zagrade (COI20_zagrade) | C++20 | 228 ms | 776 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int main(){
int n, q, check;
string ans;
vector<ii> paired;
cin>>n>>q;
int ptr=1;
int counter=0;
stack<int> singlepos;
while(ptr<n+1){
if(ptr==n){
ptr++;
continue;
}
cout<<"? "<<ptr<<' '<<ptr+1<<endl;
cin>>check;
if(check==0){
ans+='(';
singlepos.push(ptr);
++ptr;
}else{
ans+="()";
ptr+=2;
while(check==1){
if(singlepos.empty()) break;
cout<<"? "<<singlepos.top()<<' '<<ptr<<endl;
cin>>check;
if(check==1){
ans+=')';
singlepos.pop();
ptr++;
}
}
}
}
while(ans.length()<n){
ans+=')';
}
cout<<"! "<<ans;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
