| Task: | Hamilton |
| Sender: | Asarbardjarn |
| Submission time: | 2026-04-17 13:05:30 +0300 |
| Language: | C++ (C++23) |
| Status: | READY |
| Result: | 89 |
| subtask | verdict | score |
|---|---|---|
| #1 | TIME LIMIT EXCEEDED | 0 |
| #2 | ACCEPTED | 7 |
| #3 | ACCEPTED | 12 |
| #4 | ACCEPTED | 70 |
| test | verdict | time | score | subtask | |
|---|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.01 s | 0 | details | |
| #2 | TIME LIMIT EXCEEDED | -- | 0 | 1 | details |
| #3 | ACCEPTED | 11.26 s | 100 | 2, 3 | details |
| #4 | ACCEPTED | 19.20 s | 92 | 4 | details |
Compiler report
input/code.cpp: In lambda function:
input/code.cpp:58:34: warning: comparison of integer expressions of different signedness: 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
58 | while ((g() & k) == k);
| ~~~~~~~~~~^~~~Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
constexpr const int T = 1e5;
random_device rd;
mt19937 g(rd());
void gen() {
vector<vector<bool>> v(n, vector<bool>(n, 0));
for (int i = 0; i < n; i++)
for (int j = i+1; j < n; j++)
// v[i][j] = (n + i - j) % n <= (n + j - i) % n, v[j][i] = !v[i][j];
v[i][j] = g() & 1, v[j][i] = !v[i][j];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) cout << v[i][j];
cout << endl;
}
}
void solve() {
vector<vector<int>> Q(n, vector<int>(n, -1));
auto que = [&](int i, int j) -> bool {
assert (i != j);
if (~Q[i][j]) return Q[i][j];
cout << "? " << i + 1 << ' ' << j + 1 << endl;
char c; cin >> c;
Q[i][j] = c == '>';
Q[j][i] = !Q[i][j];
return Q[i][j];
};
vector<vector<int>> V;
for (int i = 0; i < n-1; i += 2) {
V.push_back({i, i+1});
if (que(i+1, i)) swap(V.back()[0], V.back()[1]);
}
int cnt = 0;
auto split = [&](int k) -> void {
cnt = 0;
do {
size_t mx = 0;
for (auto v : V) mx = max(v.size(), mx);
if (mx < 2) break;
int i = g() % V.size();
while (V[i].size() == 1) i = g() % V.size();
vector<int> w;
size_t x = g() % (V[i].size() - 1) + 1;
while (V[i].size() > x) w.push_back(V[i].back()), V[i].pop_back();
reverse(w.begin(), w.end());
V.push_back(w);
shuffle(V.begin(), V.end(), g);
}
while ((g() & k) == k);
};
while (1) {
if (V.size() == 1) {
if (que(V[0].back(), V[0].front())) break;
split((1<<11) - 1);
continue;
}
if (cnt >= T) {
split((1<<30) - 1);
continue;
}
int i = g() % V.size(), j = i;
while (j == i) j = g() % V.size();
if (que(V[i].back(), V[j].front())) {
for (int x : V[j]) V[i].push_back(x);
V.erase(V.begin() + j);
cnt = 0;
}
else cnt++;
}
cout << '!';
for (int x : V[0]) cout << ' ' << x + 1;
cout << endl;
}
int main(int argc, char** argv) {
ios_base::sync_with_stdio(0); cin.tie(0);
int t; cin >> n >> t;
gen();
while (t--) solve();
}
Test details
Test 1
Subtask:
Verdict: WRONG ANSWER
| input |
|---|
| 0 5 2 fixed 1 2 3 4 5 2 4 1 5 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| Activating encoder mode 5 2 00100 10000 01011 ... |
Feedback: Formatting error
Test 2
Subtask: 1
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 01 4 200 rnd |
| correct output |
|---|
| (empty) |
| user output |
|---|
| (empty) |
Test 3
Subtask: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 02 50 200 rnd |
| correct output |
|---|
| (empty) |
| user output |
|---|
| Activating encoder mode 50 200 000011111010011110001110111001... |
Feedback: Q = 91.235000
Test 4
Subtask: 4
Verdict: ACCEPTED
| input |
|---|
| 03 500 200 rnd |
| correct output |
|---|
| (empty) |
| user output |
|---|
| Activating encoder mode 500 200 011101010110011101100110101110... |
Feedback: Q = 764.260000
