Submission #706365

#TimeUsernameProblemLanguageResultExecution timeMemory
706365vjudge1Zagrade (COI20_zagrade)C++17
100 / 100
854 ms1420 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...