#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
// #define int long long
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;
const int MXN = 260;
int n;
bitset<MXN> b;
int a[MXN][MXN];
vector<int> p;
vector<int> ans;
#ifdef MIKU
int query(vector<int> v) {
// for (auto &i : v) cout << i << ' ';
// cout << endl;
// cout << "5 3 7 1 6 2 4" << endl;
int x;
cin >> x;
return x;
}
#endif
int ccc = 0;
int QUERY(vector<int> v) {
int x = query(v);
assert(++ccc == 5040);
if (x == n) exit(0);
return x;
}
vector<int> ept() {
vector<int> v;
FOR(i, 0, n) if (!b[i]) v.push_back(i);
return v;
}
void SET(int c) {
vector<int> v = ept();
cout << "v: ";
for (auto &i : v) cout << i << ' ';
cout << endl;
int x = v[0];
vector<int> w(v.size());
FOR(i, 1, v.size()) {
swap(p[v[0]], p[v[i]]);
w[i] = QUERY(p) - c;
swap(p[v[0]], p[v[i]]);
}
if (*max_element(w.begin() + 1, w.end()) == *min_element(w.begin() + 1, w.end())) {
ans[0] = p[v[0]];
b[v[0]] = true;
return;
}
x = *min_element(w.begin() + 1, w.end());
FOR(i, 1, w.size()) if (w[i] == x) {
ans[v[i]] = p[v[i]];
b[v[i]] = true;
}
if (x == -2) {
ans[0] = p[v[0]];
b[v[0]] = true;
}
}
void ROTATE(vector<int> &v, int c) {
vector<int> w(v.size());
FOR(i, 0, v.size()) w[i] = p[v[i]];
rotate(w.begin(), w.begin() + c, w.end());
FOR(i, 0, v.size()) p[v[i]] = w[i];
}
void calc(int s) {
vector<int> v = ept();
// cout << "calc v: ";
// for (auto &i : v) cout << i << ' ';
// cout << endl;
vector<pii> w;
ROTATE(v, 1);
FOR(i, 1, v.size()) {
w.emplace_back(QUERY(p) - s, i);
ROTATE(v, 1);
}
auto [x, y] = *max_element(w.begin(), w.end());
ROTATE(v, y);
SET(x);
}
void solve(int _n) {
n = _n;
FOR(i, 0, n) b[i] = false;
p.resize(n);
ans.resize(n);
vector<pii> v;
FOR(i, 0, n) p[i] = i + 1;
FOR(i, 0, n) {
v.emplace_back(QUERY(p), i);
rotate(p.begin(), p.begin() + 1, p.end());
}
auto [x, y] = *max_element(v.begin(), v.end());
rotate(p.begin(), p.begin() + y, p.end());
SET(x);
int pre = b.count();
while (b.count() < n) {
calc(b.count());
if (pre == b.count()) assert(false);
pre = b.count();
}
}
#ifdef MIKU
int32_t main() {
solve(7);
}
#endif
Compilation message
mouse.cpp: In function 'void solve(int)':
mouse.cpp:111:22: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
111 | while (b.count() < n) {
| ~~~~~~~~~~^~~
mouse.cpp:113:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::size_t' {aka 'long unsigned int'} [-Wsign-compare]
113 | if (pre == b.count()) assert(false);
| ~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
444 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
444 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
444 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |