Submission #1171799

#TimeUsernameProblemLanguageResultExecution timeMemory
1171799peterandvoiZagrade (COI20_zagrade)C++20
100 / 100
237 ms1152 KiB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "C:\debug.h"
#else
#define debug(...) 42
#endif

bool ask(int l, int r) {
  cout << "? " << l + 1 << " " << r + 1 << endl;
  bool x; cin >> x; return x;
}

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(nullptr);
  int n, q; cin >> n >> q;
  string res(n, ')');
  vector<int> st;
  for (int i = 0; i < n; ++i) {
    if (!st.empty() && ask(st.back(), i)) {
      res[st.back()] = '(';
      st.pop_back();
    } else st.push_back(i);
  }
  for (int i = st.size() / 2; i < (int) st.size(); ++i) res[st[i]] = '(';
  cout << "! " << res << 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...