Submission #315077

#TimeUsernameProblemLanguageResultExecution timeMemory
315077Kevin_Zhang_TWMouse (info1cup19_mouse)C++17
40.67 / 100
347 ms384 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...