Submission #706365

# Submission time Handle Problem Language Result Execution time Memory
706365 2023-03-06T10:33:39 Z vjudge1 Zagrade (COI20_zagrade) C++17
100 / 100
854 ms 1420 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
// #define endl '\n'

const int M = 4e5+5, MOD = 998244353;
char s[M];
signed main() {
    cin.tie(0)->sync_with_stdio(0);
    
    int n, q;
    cin >> n >> q;

    int cnt = n/2;
    stack<int> st;
    for (int i = 1; i <= n; i++) {
        if (!st.size()) st.push(i);
        else {
            cout << "? " << st.top() << ' ' << i << endl;
            int x;
            cin >> x;

            if (x) cnt--, s[i]=')', s[st.top()] = '(', st.pop();
            else st.push(i);
        }
    }

    cout << "! ";
    for (int i = 1; i <= n; i++)
        if (!s[i]) cnt?s[i]=')', cnt--:s[i]='(';
    for (int i = 1; i <= n; i++) cout << s[i]; cout << endl;

    return 0;
}
/*
1234567890123456
))(()(())()(()()
)))()(())())()()
16 0 0 0 0 1 0 0 1 1 0 1 0 0 1 0 1
*/

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:32:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   32 |     for (int i = 1; i <= n; i++) cout << s[i]; cout << endl;
      |     ^~~
zagrade.cpp:32:48: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   32 |     for (int i = 1; i <= n; i++) cout << s[i]; cout << endl;
      |                                                ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 3 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 7 ms 324 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 8 ms 324 KB Output is correct
5 Correct 10 ms 316 KB Output is correct
6 Correct 4 ms 324 KB Output is correct
7 Correct 6 ms 208 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 384 ms 464 KB Output is correct
3 Correct 747 ms 472 KB Output is correct
4 Correct 652 ms 616 KB Output is correct
5 Correct 782 ms 740 KB Output is correct
6 Correct 835 ms 716 KB Output is correct
7 Correct 713 ms 872 KB Output is correct
8 Correct 816 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 680 ms 1420 KB Output is correct
3 Correct 782 ms 696 KB Output is correct
4 Correct 833 ms 956 KB Output is correct
5 Correct 854 ms 588 KB Output is correct
6 Correct 830 ms 832 KB Output is correct
7 Correct 346 ms 672 KB Output is correct
8 Correct 839 ms 444 KB Output is correct