結果

問題 No.2085 Directed Complete Graph
ユーザー 👑 emthrmemthrm
提出日時 2022-10-16 06:19:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 2,227 bytes
コンパイル時間 2,379 ms
コンパイル使用メモリ 203,624 KB
実行使用メモリ 24,216 KB
平均クエリ数 2472.00
最終ジャッジ日時 2023-09-09 11:08:01
合計ジャッジ時間 5,765 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,880 KB
testcase_01 AC 24 ms
23,376 KB
testcase_02 AC 153 ms
23,412 KB
testcase_03 AC 141 ms
23,208 KB
testcase_04 AC 157 ms
24,216 KB
testcase_05 AC 82 ms
24,204 KB
testcase_06 AC 89 ms
23,412 KB
testcase_07 AC 145 ms
23,376 KB
testcase_08 AC 115 ms
23,628 KB
testcase_09 AC 145 ms
23,412 KB
testcase_10 AC 150 ms
23,892 KB
testcase_11 AC 149 ms
23,520 KB
testcase_12 AC 146 ms
24,048 KB
testcase_13 AC 146 ms
23,400 KB
testcase_14 AC 148 ms
23,532 KB
testcase_15 AC 24 ms
23,400 KB
testcase_16 AC 24 ms
23,820 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:28: 警告: "ONLINE_JUDGE" が再定義されました
   28 | #define ONLINE_JUDGE
      | 
<コマンドライン>: 備考: ここが以前の宣言がある位置です

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1};
constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1};
constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U>
inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U>
inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
constexpr int N = 500;
bool has_edge[N][N]{};

int q = 0;
#endif

bool query(const int a, const int b) {
#ifndef ONLINE_JUDGE
  ++q;
  return has_edge[a][b];
#else
  cout << "? " << a + 1 << ' ' << b + 1 << endl;
  int t; cin >> t;
  assert(t != -1);
  return t == 1;
#endif
}

int main() {
  int n; cin >> n;
#ifndef ONLINE_JUDGE
  int m; cin >> m;
  assert(n * (n - 1) / 2 == m);
  while (m--) {
    int a, b; cin >> a >> b; --a; --b;
    has_edge[a][b] = true;
  }
#endif
  vector<int> c(n);
  iota(ALL(c), 0);
  const auto merge_sort = [&](auto&& merge_sort, const int l, const int r) -> void {
    if (l + 1 == r) return;
    const int m = (l + r) / 2;
    merge_sort(merge_sort, l, m);
    merge_sort(merge_sort, m, r);
    vector<int> a;
    a.reserve(r - l);
    int i = l, j = m;
    while (i < m && j < r) a.emplace_back(c[(query(c[i], c[j]) ? i : j)++]);
    for (; i < m; ++i) {
      a.emplace_back(c[i]);
    }
    for (; j < r; ++j) {
      a.emplace_back(c[j]);
    }
    copy(ALL(a), c.begin() + l);
  };
  merge_sort(merge_sort, 0, n);
#ifndef ONLINE_JUDGE
  cout << "query: " << q << '\n';
#endif
  cout << "!\n" << n - 1 << '\n';
  REP(i, n) {
    cout << c[i] + 1;
    if (i + 1 == n) {
      cout << endl;
    } else {
      cout << ' ';
    }
  }
  return 0;
}
0