結果
| 問題 |
No.2085 Directed Complete Graph
|
| ユーザー |
emthrm
|
| 提出日時 | 2022-10-16 06:19:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 167 ms / 2,000 ms |
| コード長 | 2,227 bytes |
| コンパイル時間 | 2,085 ms |
| コンパイル使用メモリ | 197,900 KB |
| 最終ジャッジ日時 | 2025-02-08 07:00:37 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 |
コンパイルメッセージ
main.cpp:28: warning: "ONLINE_JUDGE" redefined
28 | #define ONLINE_JUDGE
|
<command-line>: note: this is the location of the previous definition
ソースコード
#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;
}
emthrm