이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
char result[100001];
int main() {
int N, Q;
stack<int>tunggu;
cin >> N >> Q;
int half=N/2;
bool apa;
for (int i=1; i<=N; i++) {
if(tunggu.empty()==true) {
tunggu.push(i);
} else {
cout << "? " << tunggu.top() << " " << i << endl;
cin >> apa;
if(apa==true) {
result[tunggu.top()]='(';
result[i]=')';
half--;
tunggu.pop();
} else {
tunggu.push(i);
}
}
}
while(!tunggu.empty()) {
if(half!=0) {
result[tunggu.top()]='(';
half--;
tunggu.pop();
} else {
result[tunggu.top()]=')';
tunggu.pop();
}
}
for (int i=1; i<=N; i++) {
cout << result[i];
}
cout << endl;
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... |