# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
651087 |
2022-10-17T02:38:49 Z |
_HDH |
Zagrade (COI20_zagrade) |
C++11 |
|
958 ms |
924 KB |
#include <bits/stdc++.h>
#ifdef LOCAL
#include <debug.h>
#else
#define debug(...) 1001
#endif
using namespace std;
#define all(x) x.begin(), x.end()
#define st first
#define nd second
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define file "TEMPLATE"
typedef long long ll;
typedef pair<int, int> ii;
typedef array<int, 3> iii;
typedef vector<int> vi;
typedef vector<ll> vl;
bool const SINGLE_TEST = 1;
bool ask(int l, int r){
cout << "? " << l << " " << r << "\n";
cout.flush();
bool ans; cin >> ans;
return ans;
}
void answer(string s){
cout << "!" << s << "\n";
cout.flush();
}
void solve(){
int n, q; cin >> n >> q;
string s = " (";
deque<int> que;
que.pb(1);
for (int i = 2; i <= n; i++){
if (que.empty()) que.pb(i), s.pb('(');
else{
if (ask(que.back(), i)){
que.pob(), s.pb(')');
}else que.pb(i), s.pb('(');
}
}
answer(s);
}
int main(){
ios_base::sync_with_stdio(0);// the
cin.tie(0);cout.tie(0);// magical lines
// freopen(file".inp", "r", stdin);
// freopen(file".out", "w", stdout);
int t;
if (SINGLE_TEST) t = 1;
else cin >> t;
while (t--) solve();
return 0;
}//it's coding time!
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
4 ms |
208 KB |
Output is correct |
3 |
Correct |
11 ms |
208 KB |
Output is correct |
4 |
Correct |
6 ms |
312 KB |
Output is correct |
5 |
Correct |
10 ms |
208 KB |
Output is correct |
6 |
Correct |
8 ms |
312 KB |
Output is correct |
7 |
Correct |
4 ms |
320 KB |
Output is correct |
8 |
Correct |
8 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
285 ms |
616 KB |
Output is correct |
3 |
Correct |
737 ms |
632 KB |
Output is correct |
4 |
Correct |
550 ms |
572 KB |
Output is correct |
5 |
Correct |
958 ms |
740 KB |
Output is correct |
6 |
Correct |
704 ms |
592 KB |
Output is correct |
7 |
Correct |
831 ms |
924 KB |
Output is correct |
8 |
Correct |
743 ms |
756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |