結果

問題 No.850 企業コンテスト2位
ユーザー risujirohrisujiroh
提出日時 2019-07-05 22:36:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 2,652 ms
コンパイル使用メモリ 172,796 KB
実行使用メモリ 24,408 KB
平均クエリ数 200.11
最終ジャッジ日時 2023-09-23 17:31:52
合計ジャッジ時間 4,313 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,940 KB
testcase_01 AC 26 ms
23,508 KB
testcase_02 AC 25 ms
23,916 KB
testcase_03 AC 26 ms
23,616 KB
testcase_04 AC 25 ms
23,964 KB
testcase_05 AC 25 ms
23,952 KB
testcase_06 AC 26 ms
23,772 KB
testcase_07 AC 29 ms
23,940 KB
testcase_08 AC 31 ms
23,592 KB
testcase_09 AC 31 ms
23,652 KB
testcase_10 AC 36 ms
23,772 KB
testcase_11 AC 36 ms
23,364 KB
testcase_12 AC 36 ms
23,940 KB
testcase_13 AC 36 ms
23,508 KB
testcase_14 AC 35 ms
23,940 KB
testcase_15 AC 35 ms
23,328 KB
testcase_16 AC 34 ms
24,408 KB
testcase_17 AC 36 ms
23,952 KB
testcase_18 AC 35 ms
23,892 KB
testcase_19 AC 36 ms
23,376 KB
testcase_20 AC 36 ms
23,520 KB
testcase_21 AC 36 ms
23,364 KB
testcase_22 AC 36 ms
23,340 KB
testcase_23 AC 36 ms
23,976 KB
testcase_24 AC 36 ms
23,352 KB
testcase_25 AC 36 ms
23,340 KB
testcase_26 AC 36 ms
23,964 KB
testcase_27 AC 26 ms
23,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  int n; cin >> n;
  auto fn = [&](V<> id) -> VV<> {
    VV<> v{id};
    while (id.size() >= 2) {
      int m = id.size();
      V<> nid;
      for (int i = 0; i < m; i += 2) {
        if (i + 1 < m) {
          cout << "? " << id[i] << ' ' << id[i + 1] << endl;
          int x; cin >> x;
          nid.push_back(x);
        } else nid.push_back(id[i]);
      }
      swap(id, nid);
      v.push_back(id);
    }
    return v;
  };
  V<> id(n);
  iota(begin(id), end(id), 1);
  auto v = fn(id);
  int x = v.back().back();
  V<>().swap(id);
  for (const auto& e : v) {
    int m = e.size();
    for (int i = 0; i < m; ++i) if (e[i] == x) {
      if ((i ^ 1) < m) id.push_back(e[i ^ 1]);
    }
  }
  int res = fn(id).back().back();
  cout << "! " << res << endl;
}
0