結果

問題 No.1959 Prefix MinMax
ユーザー tnakao0123tnakao0123
提出日時 2022-05-28 02:29:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 1,145 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 43,152 KB
実行使用メモリ 24,624 KB
平均クエリ数 26.72
最終ジャッジ日時 2023-10-20 22:25:14
合計ジャッジ時間 4,402 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,612 KB
testcase_01 AC 26 ms
24,612 KB
testcase_02 AC 25 ms
24,612 KB
testcase_03 AC 24 ms
24,612 KB
testcase_04 AC 25 ms
24,612 KB
testcase_05 AC 25 ms
24,612 KB
testcase_06 AC 25 ms
24,612 KB
testcase_07 AC 37 ms
24,612 KB
testcase_08 AC 38 ms
24,612 KB
testcase_09 AC 37 ms
24,612 KB
testcase_10 AC 37 ms
24,612 KB
testcase_11 AC 37 ms
24,612 KB
testcase_12 AC 39 ms
24,612 KB
testcase_13 AC 39 ms
24,612 KB
testcase_14 AC 39 ms
24,612 KB
testcase_15 AC 37 ms
24,612 KB
testcase_16 AC 38 ms
24,612 KB
testcase_17 AC 37 ms
24,612 KB
testcase_18 AC 39 ms
24,612 KB
testcase_19 AC 38 ms
24,612 KB
testcase_20 AC 38 ms
24,612 KB
testcase_21 AC 39 ms
24,612 KB
testcase_22 AC 37 ms
24,612 KB
testcase_23 AC 37 ms
24,612 KB
testcase_24 AC 37 ms
24,612 KB
testcase_25 AC 37 ms
24,612 KB
testcase_26 AC 37 ms
24,612 KB
testcase_27 AC 37 ms
24,612 KB
testcase_28 AC 37 ms
24,612 KB
testcase_29 AC 37 ms
24,612 KB
testcase_30 AC 37 ms
24,612 KB
testcase_31 AC 38 ms
24,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1959.cc:  No.1959 Prefix MinMax - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

/* global variables */

int as[MAX_N], bs[MAX_N], ps[MAX_N];

/* subroutines */

void query(int n, int as[], int bs[]) {
  putchar('?');
  for (int i = 0; i < n - 1; i++) printf(" %d", as[i]);
  putchar('\n'); fflush(stdout);

  for (int i = 0; i < n; i++) {
    scanf("%d", bs + i);
    if (bs[i] < 1 || bs[i] > n) exit(0);
  }
}

/* main */

int main() {
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    int n;
    scanf("%d", &n);

    fill(ps, ps + n, 0);

    for (int i = 0; i < n - 1; i++) as[i] = (i & 1);
    query(n, as, bs);

    for (int i = 0, pb = -1; i < n; i++)
      if (pb != bs[i]) pb = ps[i] = bs[i];

    for (int i = 0; i < n - 1; i++) as[i] = (i & 1) ^ 1;
    query(n, as, bs);

    for (int i = 0, pb = -1; i < n; i++)
      if (pb != bs[i]) pb = ps[i] = bs[i];

    putchar('!');
    for (int i = 0; i < n; i++) printf(" %d", ps[i]);
    putchar('\n'); fflush(stdout);
  }

  //sleep(1);
  return 0;
}
0