답안 #640211

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
640211 2022-09-14T01:55:52 Z christinelynn Zagrade (COI20_zagrade) C++17
71 / 100
916 ms 1508 KB
#include <bits/stdc++.h>
using namespace std;

#define nyahalo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define otsumiko exit(0);
#define mikodanye priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > >
#define mikochi priority_queue<long long, vector<long long>, greater<long long> >

long long n, q, x, a[100069], pi;
stack<long long> stk;

int main() {
  nyahalo
  long long i, j;
  cin >> n >> q;
  for (i=1; i<=n; i++) {
    a[i] = 0;
  }
  a[1] = 1;
  stk.push(1);
  for (i=2; i<=n; i++) {
    if (stk.empty()) {
      stk.push(i);
      a[i] = 1;
    } else {
      pi = stk.top();
      cout << "? " << pi << " " << i << "\n" << flush;
      cin >> x;
      if (x == 1) {
        a[i] = -1;
        stk.pop();
      } else {
        a[i] = 1;
        stk.push(i);
      }
    }
  }
  cout << "! ";
  for (i=1; i<=n; i++) {
    if (a[i] == 1) {
      cout << "(";
    } else {
      cout << ")";
    }
  }
  cout << "\n" << flush;
  otsumiko
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:14:16: warning: unused variable 'j' [-Wunused-variable]
   14 |   long long i, j;
      |                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 8 ms 336 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 11 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 10 ms 336 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 472 ms 1080 KB Output is correct
3 Correct 916 ms 1124 KB Output is correct
4 Correct 843 ms 1152 KB Output is correct
5 Correct 834 ms 1104 KB Output is correct
6 Correct 626 ms 1084 KB Output is correct
7 Correct 761 ms 1508 KB Output is correct
8 Correct 742 ms 1084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -