이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb emplace_back
#define AI(i) begin(i), end(i)
using namespace std;
using ll = long long;
const int MAX_N = 300;
int n;
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
void kout(){ cerr << endl; }
template<class T1, class ...T2> void kout(T1 a, T2 ...e) { cerr << a << ' ', kout(e...); }
vector<int> p{1,2,3,4,5,6,7,8,9,10,11,12,13};
int qcnt;
int query(vector<int> q) {
++qcnt;
int res = 0;
for (int i = 0;i < n;++i)
res += p[i] == q[i];
if (res == n)
DE(n, qcnt);
return res;
}
#else
#define DE(...) 0
void debug(...) {}
#include "grader.h"
#endif
random_device rd;
mt19937 gen(rd());
void solve(int N) {
n = N;
vector<int> q(n);
vector<bool> done(n);
iota(AI(q), 1);
shuffle(AI(q), gen);
int cnt = query(q);
for (int i = 0;i < n && cnt < n;++i) {
if (done[i]) continue;
vector<int> good;
for (int j = i+1;j < n && cnt < n;++j) {
if (done[j]) continue;
swap(q[i], q[j]);
int v = query(q);
swap(q[i], q[j]);
if (v > cnt) {
swap(q[i], q[j]);
cnt = v;
good.pb(j);
continue;
}
if (v == cnt - 2) {
done[i] = done[j] = true;
break;
}
}
if (good.size() < 2) continue;
good.pop_back();
for (int u : good)
done[u] = true;
}
}
#ifdef KEV
int main() {
solve(p.size());
}
#endif
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |