結果

問題 No.2085 Directed Complete Graph
ユーザー noshi91noshi91
提出日時 2022-09-26 22:26:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 616 bytes
コンパイル時間 2,328 ms
コンパイル使用メモリ 214,340 KB
実行使用メモリ 24,444 KB
平均クエリ数 2418.82
最終ジャッジ日時 2023-08-24 03:12:06
合計ジャッジ時間 5,408 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,976 KB
testcase_01 AC 23 ms
23,868 KB
testcase_02 WA -
testcase_03 AC 162 ms
23,964 KB
testcase_04 WA -
testcase_05 AC 80 ms
24,036 KB
testcase_06 AC 83 ms
23,568 KB
testcase_07 AC 143 ms
23,688 KB
testcase_08 AC 114 ms
23,664 KB
testcase_09 AC 144 ms
24,444 KB
testcase_10 AC 148 ms
23,856 KB
testcase_11 AC 150 ms
23,568 KB
testcase_12 AC 148 ms
23,520 KB
testcase_13 AC 150 ms
24,336 KB
testcase_14 AC 151 ms
23,580 KB
testcase_15 AC 24 ms
24,288 KB
testcase_16 AC 25 ms
23,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int main() {
  int N;
  std::cin >> N;
  std::map<std::pair<int, int>, bool> memo;
  auto comp = [&](int i, int j) {
    if (i == j) {
      return false;
    }
    if (!memo.count({i, j})) {
      std::cout << "? " << i << " " << j << "\n";
      int T;
      std::cin >> T;
      memo[{i, j}] = T;
      memo[{j, i}] = !T;
    }
    return memo[{i, j}];
  };

  std::vector<int> v(N);
  std::iota(v.begin(), v.end(), 1);
  std::stable_sort(v.begin(), v.end(), comp);
  std::cout << "!\n" << N - 1 << "\n";
  for (int i = 0; i < N; i++) {
    std::cout << v[i] << " \n"[i + 1 == N];
  }
}
0