# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
559100 | Redhood | Zagrade (COI20_zagrade) | C++14 | 0 ms | 336 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define pb push_back
#define mkp make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
bool ask(int i , int j){
cout << "? " << i + 1 << ' ' << j + 1 << endl;
int ans;
cin >> ans;
return ans;
}
signed main(){
int n , q;
cin >> n >> q;
stack < int > pos;
pos.push(0);
string s = string(n, '(');
int did=0;
int need = n / 2;
cout << s << endl;
for(int i = 1; i < n; ++i){
if(pos.empty()){
pos.push(i);
continue;
}
int f = pos.top();
if(ask(f , i)){
s[f] = '(';
s[i] = ')';
did++;
pos.pop();
}else{
pos.push(i);
}
}
assert(sz(pos) % 2 == 0);
int f = sz(pos) / 2;
for(int t=0;t<f;++t){
s[pos.top()] = '(';
pos.pop();
}
for(int t=0;t<f;++t){
s[pos.top()] = ')';
pos.pop();
}
cout << "! " << s << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |