# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
651092 | 2022-10-17T03:16:29 Z | _HDH | Zagrade (COI20_zagrade) | C++17 | 917 ms | 936 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; scanf("%d%d", &n, &q); string s(n + 1, ' '); stack<int> st; for (int i = 1; i <= n; i++){ if (!st.empty() && ask(st.top(), i)){ s[st.top()] = '('; s[i] = ')'; st.pop(); }else st.push(i); } int z = st.size() / 2; while (!st.empty()){ if (st.size() <= z) s[st.top()] = ')'; else s[st.top()] = '('; st.pop(); } // for (int i = 1; i <= n / 2; i++) // s[i] = '('; // for (int i = n / 2 + 1; i <= n; i++) // s[i] = ')'; 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!
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 8 ms | 208 KB | Output is correct |
3 | Correct | 9 ms | 296 KB | Output is correct |
4 | Correct | 9 ms | 208 KB | Output is correct |
5 | Correct | 10 ms | 208 KB | Output is correct |
6 | Correct | 10 ms | 208 KB | Output is correct |
7 | Correct | 11 ms | 208 KB | Output is correct |
8 | Correct | 8 ms | 324 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 10 ms | 304 KB | Output is correct |
3 | Correct | 8 ms | 312 KB | Output is correct |
4 | Correct | 10 ms | 208 KB | Output is correct |
5 | Correct | 11 ms | 208 KB | Output is correct |
6 | Correct | 9 ms | 208 KB | Output is correct |
7 | Correct | 8 ms | 208 KB | Output is correct |
8 | Correct | 10 ms | 208 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 445 ms | 528 KB | Output is correct |
3 | Correct | 788 ms | 528 KB | Output is correct |
4 | Correct | 807 ms | 524 KB | Output is correct |
5 | Correct | 855 ms | 528 KB | Output is correct |
6 | Correct | 832 ms | 532 KB | Output is correct |
7 | Correct | 868 ms | 720 KB | Output is correct |
8 | Correct | 870 ms | 528 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 876 ms | 936 KB | Output is correct |
3 | Correct | 850 ms | 592 KB | Output is correct |
4 | Correct | 851 ms | 760 KB | Output is correct |
5 | Correct | 739 ms | 696 KB | Output is correct |
6 | Correct | 767 ms | 900 KB | Output is correct |
7 | Correct | 917 ms | 708 KB | Output is correct |
8 | Correct | 791 ms | 524 KB | Output is correct |