답안 #640281

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
640281 2022-09-14T05:42:25 Z kith14 Zagrade (COI20_zagrade) C++14
0 / 100
1384 ms 1232 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define db double
#define pairll pair<ll,ll>
#define lpairll pair<ll,pairll>

#define repp(i,a,b) for (ll i = a; i <= b; i++)
#define repz(i,a,b) for (ll i = a; i < b; i++)
#define repm(i,a,b) for (ll i = a; i >= b; i--)
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

const ll N = 1e5+5, MOD = 1e9+7;
ll tc = 1, n, m, fnd[N];
ll x, y, k;
string s, s1, s2, ye = "YES", no = "NO";
char cr[N];

void input(){
  cin >> n >> k; 
}

void solve(){
  ll tot = 0;

  for (ll i = 1; i <= n; i++){
    for (ll j = i+1; j <= n; j += 2){
      cout << "? " << i << " " << j << endl;
      cout.flush();
      cin >> m;
      if (m == 1){
        cr[i] = '(';
        cr[j] = ')';
        if (fnd[i] == 0){
          fnd[i] = 1;
          tot++;
        }
        if (fnd[j] == 0){
          fnd[j] = 1;
          tot++;
        }
      }
      if (tot >= n) break;
    }
    if (tot >= n) break;
  }

  cout << "! ";
  for (ll i = 1; i <= n; i++){
    cout << cr[i];
  }
  cout << endl;
  cout.flush();
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  //cin >> tc;
  while(tc--){
    input();
    solve();
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Runtime error 1384 ms 316 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Runtime error 567 ms 1232 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -