Submission #1152457

#TimeUsernameProblemLanguageResultExecution timeMemory
1152457yhkhooZagrade (COI20_zagrade)C++20
0 / 100
235 ms528 KiB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
#define fi first
#define se second

int main(){
    cin.tie(0); ios_base::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    char ans[n];
    memset(ans, '?', sizeof(ans));
    int s=0, pe=-8, ps=-8;
    for(int e=1; e<n; e++){
        cout << '?' << ' ' << s+1 << ' ' << e+1 << endl;
        bool temp;
        cin >> temp;
        if(temp){
            ans[s] = '(';
            ans[e] = ')';
            if(s == 0){
                s = e;
                pe = -8;
                continue;
            }
            if(s - pe == 1){
                s = ps-1;
            }
            else{
                ps = s;
                s = s-1;
            }
            pe = e;
        }
        else{
            s = e;
        }
    }
    int qc = 0;
    int tqc = 0;
    for(int i=0; i<n; i++){
        if(ans[i] == '?'){
            tqc++;
        }
    }
    cout << '!' << ' ';
    for(int i=0; i<n; i++){
        if(ans[i] == '?'){
            qc++;
            if(qc > tqc/2){
                ans[i] = '(';
            }
            else{
                ans[i] = ')';
            }
        }
        cout << ans[i];
    }
    cout << endl;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...