Submission #677355

#TimeUsernameProblemLanguageResultExecution timeMemory
677355Ninja_KunaiRarest Insects (IOI22_insects)C++17
89.88 / 100
97 ms532 KiB
/** * Author : Nguyen Tuan Vu * Created : 03.01.2023 **/ #pragma GCC optimize("O2") #pragma GCC target("avx,avx2,fma") #include<bits/stdc++.h> #define MASK(x) ((1ll)<<(x)) #define BIT(x, i) (((x)>>(i))&(1)) #define ALL(v) (v).begin(), (v).end() #define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i) #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; --i) template <class X, class Y> bool minimize(X &a, Y b) { if (a > b) return a = b, true; return false; } template <class X, class Y> bool maximize(X &a, Y b) { if (a < b) return a = b, true; return false; } using namespace std; mt19937 jdg(chrono::steady_clock::now().time_since_epoch().count()); int Rand(int l, int r) {return l + jdg() % (r - l + 1);} const int N = 2e3 + 5; set <int> machine; void move_inside(int i); void move_outside(int i); int press_button(); long long min_cardinality(int n) { REP(i, n) { move_inside(i); if (press_button() > 1) move_outside(i); else machine.insert(i); } //for (auto x : machine) cout << x << ' '; //cout << '\n'; int distinct = machine.size(); int sign = 0; int l = 1, r = n / machine.size() + 1; while (r - l > 1) { int mid = (l + r) >> 1; if (sign == 0) { REP(i, n) if (machine.find(i) == machine.end()) { move_inside(i); if (press_button() > mid) { move_outside(i); } else { machine.insert(i); } } if (machine.size() == distinct * mid) l = mid; else { sign = 1; r = mid; } } else { set <int> cur = machine; for (auto x : machine) { move_outside(x); } machine.clear(); for (auto x : cur) { move_inside(x); if (press_button() > mid) move_outside(x); else machine.insert(x); } if (machine.size() == distinct * mid) sign = 0, l = mid; else { sign = 1; r = mid; } } //cout << l << ' ' << r << ' ' << sign << '\n'; } return l; }

Compilation message (stderr)

insects.cpp: In function 'long long int min_cardinality(int)':
insects.cpp:65:32: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   65 |             if (machine.size() == distinct * mid) l = mid;
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
insects.cpp:85:32: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   85 |             if (machine.size() == distinct * mid) sign = 0, l = mid;
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...