제출 #813722

#제출 시각아이디문제언어결과실행 시간메모리
813722kwongweng드문 곤충 (IOI22_insects)C++17
53.13 / 100
156 ms552 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long double ld; typedef pair<ll, ll> pll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define ms memset #define pb push_back #define fi first #define se second #define mi(i) move_inside(i) #define mo(i) move_outside(i) #define pr press_button() int L = 4; int min_cardinality(int n) { vi diff; vi used(n); FOR(i,0,n){ mi(i); int val = pr; if (val >= 2){ mo(i); }else{ diff.pb(i); used[i] = 1; } } int cnt = diff.size(); if (cnt <= L){ for (int u : diff) mo(u); vi num(cnt); FOR(i,0,n){ if (used[i]) continue; mi(i); FOR(j,0,cnt){ mi(diff[j]); if (pr >= 2){ num[j]++; } mo(diff[j]); } mo(i); } int mn = num[0]+1; FOR(i,0,cnt){ mn = min(mn, num[i]+1); } return mn; } for (int u : diff) mo(u); int l = 1; int r = n / cnt + 1; while (r-l>1){ vi used(n); int mid = (l+r)/2; int len = 0; vi a; FOR(i,0,n){ mi(i); len++; if (pr > mid){ mo(i); len--; }else{ a.pb(i); } } if (len == mid * cnt){ l = mid; }else{ r = min(len/cnt+1,mid); } for (int u : a) mo(u); } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...