답안 #781277

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781277 2023-07-13T01:52:09 Z andecaandeci Zagrade (COI20_zagrade) C++17
71 / 100
784 ms 1196 KB
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int, int>
#define fr first
#define sc second
#define query(l, r)                                                              cout << "? " << l << " " << r << endl;                                         cin >> res;
using namespace std;

const int N = 1e5 + 5;

string ans;
bool res;

signed main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  int n, q;
  cin >> n >> q;
  ans.assign(n, ' ');
  for (int i = 0; i < n / 2; i++)
    ans[i] = ')';
  for (int i = n / 2; i < n; i++)
    ans[i] = '(';
  stack<int> s;
  s.push(1);
  for (int i = 2; i <= n; i++) {
    if (s.empty()) {
      s.push(i);
      continue;
    }
    int cur = s.top();
    query(cur, i);
    if (res) {
      ans[cur - 1] = '(';
      ans[i - 1] = ')';
      s.pop();
    } else
      s.push(i);
  }
  cout << "! " << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 9 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 9 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct
8 Correct 6 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 8 ms 316 KB Output is correct
3 Incorrect 8 ms 208 KB Mismatch at position 510. Expected ), found (
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 358 ms 400 KB Output is correct
3 Correct 630 ms 400 KB Output is correct
4 Correct 580 ms 392 KB Output is correct
5 Correct 556 ms 392 KB Output is correct
6 Correct 734 ms 400 KB Output is correct
7 Correct 588 ms 804 KB Output is correct
8 Correct 654 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 784 ms 1196 KB Output is correct
3 Incorrect 740 ms 548 KB Mismatch at position 49727. Expected (, found )
4 Halted 0 ms 0 KB -