제출 #677352

#제출 시각아이디문제언어결과실행 시간메모리
677352Ninja_Kunai드문 곤충 (IOI22_insects)C++17
0 / 100
1 ms208 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) #define db(val) "["#val" = "<<(val)<<"] " 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) { FOR(i, 1, n) { move_inside(i); if (press_button() > 1) move_outside(i); else machine.insert(i); } int distinct = machine.size(); int sign = 0; int l = 0, r = n / machine.size() + 1; while (r - l > 1) { int mid = (l + r) >> 1; if (sign == 0) { FOR(i, 1, 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; } } 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; } } } cout << l; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

insects.cpp: In function 'long long int min_cardinality(int)':
insects.cpp:64:32: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   64 |             if (machine.size() == distinct * mid) l = mid;
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
insects.cpp:83:32: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   83 |             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...