結果

問題 No.2085 Directed Complete Graph
ユーザー 👑 emthrmemthrm
提出日時 2022-10-08 02:35:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,012 bytes
コンパイル時間 2,022 ms
コンパイル使用メモリ 202,808 KB
実行使用メモリ 36,240 KB
最終ジャッジ日時 2023-09-03 20:44:53
合計ジャッジ時間 8,761 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

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;

#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{0};
  FOR(i, 1, n) {
    if (query(c.back(), i)) {
      c.emplace_back(i);
    } else if (i == 1 || query(i, c.front())) {
      c.emplace(c.begin(), i);
    } else {
      int lb = 0, ub = c.size() - 1;
      while (ub - lb > 1) {
        const int mid = (lb + ub) / 2;
        (query(c[mid], i) ? lb : ub) = mid;
      }
      c.emplace(c.begin() + ub, i);
    }
  }
#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