제출 #685225

#제출 시각아이디문제언어결과실행 시간메모리
685225heeheeheehaawMouse (info1cup19_mouse)C++17
36.67 / 100
130 ms284 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; void solve(int n) { int a, i, j, k; vector<int> q, val, poz; if (n == 1) { query({1}); return; } for (i = 1; i <= n; i++) { q.push_back( i ); val.push_back( -1 ); poz.push_back( -1 ); } a = query(q); while (a < n && a > 0) { random_shuffle(q.begin(), q.end()); a = query(q); } if ( query( q ) == n ) return; for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (i != j) { if (val[i] != -1 && val[j] != -1) continue; swap(q[i], q[j]); a = query(q); if (a == 2) { val[i] = q[i]; val[j] = q[j]; } else if (a == 1) { if (val[i] == -1 && val[j] == -1) { k = ((i + 1 != j) ? i + 1 : (i + 2 < n ? i + 2 : i - 1)); swap( q[i], q[k] ); a = query( q ); if (a == 3) { val[i] = q[i]; val[j] = q[j]; val[k] = q[k]; } else if (a == 2) val[j] = q[j]; else if (a == 1) val[j] = q[j]; else val[i] = q[k]; swap(q[i], q[k]); } else { if (val[i] != -1 &&val[i] != q[i]) val[j] = q[j]; else if (val[j] != -1 && val[j] != q[j]) val[i] = q[i]; } } swap(q[i], q[j]); } } } query( val ); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...