# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1123061 | thangdz2k7 | Zagrade (COI20_zagrade) | C++20 | 337 ms | 840 KiB |
// author : thembululquaUwU
// 3.9.2024
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
const int MaxN = 2e5;
const int mod = 1e9 + 7;
void maxl(auto &a, auto b) {a = max(a, b);}
void minl(auto &a, auto b) {a = min(a, b);}
bool ask(int a, int b){
cout << "? " << a + 1 << ' ' << b + 1 << endl;
int t; cin >> t;
return t;
}
void solve(){
int n, q; cin >> n >> q;
string ans;
ans.resize(n);
ans[0] = '(';
vector <int> stk = {0};
for (int i = 1; i < n - 1; ++ i){
if (stk.empty() || !ask(stk.back(), i)){
ans[i] = '(';
stk.pb(i);
}
else {
ans[i] = ')';
stk.pop_back();
}
}
ans[n - 1] = ')';
cout << "! " << ans << endl;
}
int main(){
if (fopen("pqh.inp", "r")){
freopen("pqh.inp", "r", stdin);
freopen("pqh.out", "w", stdout);
}
int t = 1; // cin >> t;
while (t --) solve();
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... |