Submission #950351

# Submission time Handle Problem Language Result Execution time Memory
950351 2024-03-20T08:45:42 Z Pring Mouse (info1cup19_mouse) C++17
0 / 100
0 ms 448 KB
#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 QUERY(vector<int> v) {
    int x = query(v);
    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);
    while (b.count() < n) {
        calc(b.count());
    }
}

#ifdef MIKU
int32_t main() {
    solve(7);
}
#endif

Compilation message

mouse.cpp: In function 'void solve(int)':
mouse.cpp:107:22: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  107 |     while (b.count() < n) {
      |            ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 448 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 448 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 448 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -