Submission #643641

#TimeUsernameProblemLanguageResultExecution timeMemory
643641VanillaRarest Insects (IOI22_insects)C++17
25 / 100
164 ms300 KiB
#include <bits/stdc++.h> #include "insects.h" using namespace std; int min_cardinality(int n) { vector <bool> vis (n); int tp = 0; for (int i = 0; i < n; i++){ move_inside(i); if (press_button() == 2) { move_outside(i); } else { vis[i] = 1; tp++; } } if (tp * tp <= n) { for (int i = 0; i < n; i++) if (vis[i]) move_outside(i); vector <int> type(n, -1); int l = 0; int rs = 1e9; for (int i = 0; i < n; i++){ if (type[i] != -1) continue; int k = 1; type[i] = l++; move_inside(i); for (int j = 0; j < n; j++){ if (i == j || type[j] != -1) continue; move_inside(j); // cout << i << " " << j << " " << press_button() << "\n"; if (press_button() == 2) type[j] = type[i], k++; move_outside(j); } move_outside(i); rs = min(rs, k); } return rs; } for (int i = 2; i <= n + 1; i++){ int d = 0; for (int j = 0; j < n; j++){ if (vis[j]) continue; move_inside(j); if (press_button() == i + 1) { move_outside(j); } else { vis[j] = 1; d++; } } if (d != tp) return i-1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...