Submission #337100

# Submission time Handle Problem Language Result Execution time Memory
337100 2020-12-18T11:08:39 Z MrDomino Zagrade (COI20_zagrade) C++14
100 / 100
908 ms 1496 KB
#include <bits/stdc++.h>

using namespace std;

const int N = (int) 1e5 + 7;
int n;
int q;
int a[N];
vector<int> stk;

int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    if (stk.empty()) {
      stk.push_back(i);
      a[i] = +1;
      continue;
    }
    int j = stk.back();
    cout << "? " << j << " " << i << endl;
    int ret;
    cin >> ret;
    if (ret) {
      stk.pop_back();
      a[i] = -1;
    } else {
      stk.push_back(i);
      a[i] = +1;
    }
  }
  int half = (int) stk.size() / 2;
  for (int i = 0; i < half; i++) {
    a[stk[i]] = -1;
  }
  for (int i = half; i < (int) stk.size(); i++) {
    a[stk[i]] = +1;
  }
  cout << "! ";
  for (int i = 1; i <= n; i++) {
    if (a[i] == +1) {
      cout << "(";
    } else {
      cout << ")";
    }
  }
  cout << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 5 ms 364 KB Output is correct
3 Correct 10 ms 492 KB Output is correct
4 Correct 11 ms 364 KB Output is correct
5 Correct 9 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Correct 11 ms 492 KB Output is correct
8 Correct 9 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 11 ms 364 KB Output is correct
3 Correct 8 ms 364 KB Output is correct
4 Correct 9 ms 364 KB Output is correct
5 Correct 7 ms 492 KB Output is correct
6 Correct 10 ms 364 KB Output is correct
7 Correct 9 ms 364 KB Output is correct
8 Correct 8 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 450 ms 748 KB Output is correct
3 Correct 846 ms 896 KB Output is correct
4 Correct 784 ms 876 KB Output is correct
5 Correct 851 ms 876 KB Output is correct
6 Correct 812 ms 884 KB Output is correct
7 Correct 835 ms 1396 KB Output is correct
8 Correct 753 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 778 ms 1496 KB Output is correct
3 Correct 846 ms 1180 KB Output is correct
4 Correct 908 ms 1204 KB Output is correct
5 Correct 730 ms 1080 KB Output is correct
6 Correct 816 ms 1260 KB Output is correct
7 Correct 806 ms 1292 KB Output is correct
8 Correct 787 ms 908 KB Output is correct