Submission #1081408

# Submission time Handle Problem Language Result Execution time Memory
1081408 2024-08-30T04:13:20 Z juicy Zagrade (COI20_zagrade) C++17
100 / 100
624 ms 1772 KB
#include <bits/stdc++.h>

using namespace std;

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

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  auto qry = [&](int i, int j) {
    cout << "? " << i + 1 << " " << j + 1 << endl;
    int r; cin >> r;
    return r;
  };
  int n, q; cin >> n >> q;
  string s(n, '(');
  vector<int> st{0};
  int cnt = n / 2;
  for (int i = 1; i < n; ++i) {
    if (st.size() && qry(st.back(), i)) {
      s[i] = ')';
      --cnt;
      st.pop_back();
    } else {
      st.push_back(i);
    }
  }
  for (int i = 0; i < cnt; ++i) {
    s[st[i]] = ')';
  }
  cout << "! " << s << endl;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 7 ms 344 KB Output is correct
8 Correct 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 7 ms 344 KB Output is correct
4 Correct 6 ms 600 KB Output is correct
5 Correct 8 ms 344 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 7 ms 344 KB Output is correct
8 Correct 6 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 270 ms 524 KB Output is correct
3 Correct 557 ms 600 KB Output is correct
4 Correct 576 ms 528 KB Output is correct
5 Correct 624 ms 528 KB Output is correct
6 Correct 622 ms 532 KB Output is correct
7 Correct 531 ms 1092 KB Output is correct
8 Correct 564 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 585 ms 1772 KB Output is correct
3 Correct 584 ms 984 KB Output is correct
4 Correct 541 ms 1584 KB Output is correct
5 Correct 553 ms 1144 KB Output is correct
6 Correct 545 ms 1132 KB Output is correct
7 Correct 536 ms 1160 KB Output is correct
8 Correct 568 ms 532 KB Output is correct