| Task: | Hamilton |
| Sender: | Sebastian |
| Submission time: | 2026-04-17 10:47:34 +0300 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | 0 |
| subtask | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 0 |
| #2 | RUNTIME ERROR | 0 |
| #3 | RUNTIME ERROR | 0 |
| #4 | RUNTIME ERROR | 0 |
| test | verdict | time | score | subtask | |
|---|---|---|---|---|---|
| #1 | RUNTIME ERROR | 0.01 s | 0 | details | |
| #2 | RUNTIME ERROR | 0.01 s | 0 | 1 | details |
| #3 | RUNTIME ERROR | 0.01 s | 0 | 2, 3 | details |
| #4 | RUNTIME ERROR | 0.05 s | 0 | 4 | details |
Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
mt19937 mt(time(0));
// --- JUDGE ---
ll judge_query_count;
vector<vector<bool>> judge_graph;
void judge_init(ll n) {
judge_query_count = 0;
judge_graph = vector<vector<bool>>(n, vector<bool>(n));
for (ll i = 0; i < n; i++) {
for (ll j = i+1; j < n; j++) {
bool ij = true;
judge_graph[i][j] = ij;
judge_graph[j][i] = !ij;
}
}
judge_graph[0][n-1] = false;
judge_graph[n-1][0] = true;
for (ll i = 0; i < n; i++) {
for (ll j = 0; j < n; j++) {
if (i == j) cout << "0";
else cout << judge_graph[i][j];
}
cout << endl;
}
}
// true iff u -> v (1-indexed)
bool judge_query(ll u, ll v) {
assert(u != v);
judge_query_count++;
cout << "? " << u << ' ' << v << endl;
char ans; cin >> ans;
return ans == '>';
}
// --- CONTESTANT ---
map<pair<ll, ll>, bool> mem;
bool ask(ll u, ll v) {
if (u > v) return !ask(v, u);
if (mem.count({u, v})) return mem[{u, v}];
return mem[{u, v}] = judge_query(u+1, v+1);
}
void solve(ll n) {
mem.clear();
vector<ll> a(n);
iota(all(a), 0ll);
do {
bool ok = true;
for (ll i = 0; i < n; i++) {
if (!ask(i, (i+1)%n)) ok = false;
}
if (!ok) break;
cout << "!";
for (auto &e : a) cout << ' ' << e+1;
cout << endl;
return;
} while (next_permutation(all(a)));
assert(false);
}
// --- TESTS ---
int main() {
ll n, t; cin >> n >> t;
judge_init(n);
for (ll i = 0; i < t; i++) {
solve(n);
}
}
Test details
Test 1
Subtask:
Verdict: RUNTIME ERROR
| input |
|---|
| 0 5 2 fixed 1 2 3 4 5 2 4 1 5 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| Activating encoder mode 5 2 01110 00111 00011 ... |
Feedback: Formatting error
Test 2
Subtask: 1
Verdict: RUNTIME ERROR
| input |
|---|
| 01 4 200 rnd |
| correct output |
|---|
| (empty) |
| user output |
|---|
| Activating encoder mode 4 200 0110 0011 0001 ... |
Test 3
Subtask: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 02 50 200 rnd |
| correct output |
|---|
| (empty) |
| user output |
|---|
| Activating encoder mode 50 200 011111111111111111111111111111... |
Test 4
Subtask: 4
Verdict: RUNTIME ERROR
| input |
|---|
| 03 500 200 rnd |
| correct output |
|---|
| (empty) |
| user output |
|---|
| Activating encoder mode 500 200 011111111111111111111111111111... |
Feedback: Formatting error
