結果

問題 No.2085 Directed Complete Graph
ユーザー Li Xinhua
提出日時 2026-04-25 01:06:03
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 885 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,849 ms
コンパイル使用メモリ 338,352 KB
実行使用メモリ 30,320 KB
平均クエリ数 2471.00
最終ジャッジ日時 2026-04-25 01:06:16
合計ジャッジ時間 6,116 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
  using namespace std;

  vector<int> merge_sort(int l, int r) {
      if (r - l <= 1) return {l};
      int m = (l + r) / 2;
      auto L = merge_sort(l, m);
      auto R = merge_sort(m, r);
      vector<int> res;
      int i = 0, j = 0;
      while (i < (int)L.size() && j < (int)R.size()) {
          cout << "? " << L[i] << " " << R[j] << endl;
          int t; cin >> t;
          if (t) { res.push_back(L[i]); i++; }
          else   { res.push_back(R[j]); j++; }
      }
      while (i < (int)L.size()) { res.push_back(L[i]); i++; }
      while (j < (int)R.size()) { res.push_back(R[j]); j++; }
      return res;
  }

  int main() {
      int n; cin >> n;
      auto path = merge_sort(1, n + 1);
      cout << "! " << n << endl;
      for (int i = 0; i < n; i++) {
          if (i) cout << " ";
          cout << path[i];
      }
      cout << endl;
  }
0