제출 #628063

#제출 시각아이디문제언어결과실행 시간메모리
628063Hanksburger드문 곤충 (IOI22_insects)C++17
25 / 100
54 ms336 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; bool a[2005], b[2005]; vector<int> v; int min_cardinality(int n) { if (n%1003==0) for (int i=0; i<n; i++) v.push_back(1009*i%n); else for (int i=0; i<n; i++) v.push_back(i*1003%n); int d=0; for (int i:v) { move_inside(i); b[i]=1; d++; if (press_button()>1) { move_outside(i); b[i]=0; d--; } } for (int i:v) { if (b[i]) { move_outside(i); a[i]=1; } } int r=(n-d)/d, ans=1; while (r) { int k=(r+1)/2, cnt=0; for (int i:v) { if (a[i]) continue; move_inside(i); b[i]=1; cnt++; if (press_button()>k) { move_outside(i); b[i]=0; cnt--; } } if (cnt==k*d) { for (int i:v) { if (a[i]) continue; if (b[i]) { move_outside(i); a[i]=1; } } ans+=k; r-=k; } else { for (int i:v) { if (a[i]) continue; if (b[i]) { move_outside(i); b[i]=0; } else a[i]=1; } r=k-1; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...