Submission #336928

# Submission time Handle Problem Language Result Execution time Memory
336928 2020-12-17T11:02:34 Z MrDomino Zagrade (COI20_zagrade) C++14
71 / 100
976 ms 1344 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;
    }
  }
  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 0 ms 364 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Correct 10 ms 364 KB Output is correct
4 Correct 10 ms 364 KB Output is correct
5 Correct 10 ms 364 KB Output is correct
6 Correct 10 ms 364 KB Output is correct
7 Correct 9 ms 364 KB Output is correct
8 Correct 7 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 441 ms 936 KB Output is correct
3 Correct 748 ms 600 KB Output is correct
4 Correct 898 ms 848 KB Output is correct
5 Correct 790 ms 1096 KB Output is correct
6 Correct 887 ms 1020 KB Output is correct
7 Correct 976 ms 1344 KB Output is correct
8 Correct 828 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -