Submission #726979

#TimeUsernameProblemLanguageResultExecution timeMemory
726979murad_2005Rarest Insects (IOI22_insects)C++17
0 / 100
55 ms624 KiB
#include "insects.h" #include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define pii pair<int, int> #define piii pair<int, pii> #define pb push_back #define all(v) v.begin(), v.end() #define size(v) v.size() #define f first #define s second #define INF 1e9 using namespace std; int min_cardinality(int N) { vector<int>inside(N, false); vector<int>fixed(N, false); set<int>Machine; for(int i = 0; i < N; ++i){ move_inside(i); if(press_button() > 1){ move_outside(i); }else{ Machine.insert(i); inside[i] = fixed[i] = true; } } int uni = size(Machine); int low = 2, high = N / uni, Res = 1; while(low <= high){ int mid = (low + high) >> 1; for(int i = 0; i < N; ++i){ if(uni * mid == size(Machine)) break; if(!fixed[i]){ move_inside(i); if(press_button() > mid){ move_outside(i); }else{ Machine.insert(i); inside[i] = true; } } } if(uni * mid == size(Machine)){ low = mid + 1; Res = mid; for(int i = 0; i < N; ++i){ if(inside[i]) fixed[i] = true; } }else{ high = mid - 1; for(int i = 0; i < N; ++i){ if(!inside[i]) fixed[i] = true; else if(!fixed[i]){ move_outside(i); Machine.erase(i); fixed[i] = true; } } } } return Res; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:35:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             if(uni * mid == size(Machine)) break;
      |                          ^
insects.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         if(uni * mid == size(Machine)){
      |                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...