Submission #815278

#TimeUsernameProblemLanguageResultExecution timeMemory
815278arilocRarest Insects (IOI22_insects)C++17
10 / 100
335 ms208 KiB
#include <bits/stdc++.h> #define forn(i,n) for(int i = 0; i < int(n); i++) #define forsn(i,s,n) for(int i = int(s); i < int(n); i++) #define dforn(i,n) for(int i = int(n)-1; i >= 0; i--) #define dforsn(i,s,n) for(int i = int(n)-1; i >= int(s); i--) #define fst first #define snd second #define pb push_back #define all(c) (c).begin(),(c).end() #define FAST_IO ios::sync_with_stdio(false);cin.tie(nullptr); using namespace std; typedef vector<int> vi; typedef pair<int,int> ii; typedef long long ll; int const MAXN = 2005; bitset<MAXN> done; void move_inside(int i); void move_outside(int i); int press_button(); int min_cardinality(int N) { srand(time(NULL)); int avail = N; int prv = -1, rounds = 0; while (avail > 0) { vi alive; forn(i,N) if (!done[i]) alive.pb(i); random_shuffle(all(alive)); move_inside(alive[0]); done[alive[0]] = true; int cnt = 1; vi pass; forsn(i,1,(int)alive.size()) { move_inside(alive[i]); int aux = press_button(); if (aux == 2) { move_outside(alive[i]); } else done[alive[i]] = true, cnt++, pass.pb(alive[i]); } while (!pass.empty()) { move_outside(pass.back()); pass.pop_back(); } move_outside(alive[0]); if (prv != -1 && prv != cnt) break; prv = cnt; rounds++; avail -= cnt; } return rounds; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...