Submission #1268381

#TimeUsernameProblemLanguageResultExecution timeMemory
1268381khaiiZagrade (COI20_zagrade)C++20
0 / 100
232 ms512 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    int n, q;
    cin >> n >> q;
    // cout << endl;

    vector<char> ans(n + 1, '.'), pos;
    int l = 1, r = 2;
    int res;
    ans[1] = '(';
    ans[n] = ')';

    while(0 < l && r <= n){
        cout << "? " << l << " " << r << endl;
        cin >> res;

        if(res){
            ans[l] = '(';
            ans[r] = ')';

            // l--;
            // r++;
            while(0 < l - 1 && r + 1 <= n){
                l--;
                r++;
                cout << "? " << l << " " << r << endl;
                cin >> res;
                if(res){
                    ans[l] = '(';
                    ans[r] = ')';
                } else{
                    // ans[l] = ')';
                    // ans[r] = '(';
                    break;
                }
            } 

            l = r - 1;
            // r += 1;
        } else{
            // ans[l] = ')';
            // ans[r] = '(';
        }
        l++;
        r++;
    }
    
    cout << "! ";
    // for(char i: ans) cout << i;
    for(int i = 1; i <= n; i++) cout << ans[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...