Submission #632182

#TimeUsernameProblemLanguageResultExecution timeMemory
632182beaconmcRarest Insects (IOI22_insects)C++17
100 / 100
72 ms436 KiB
#include "insects.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; #define FOR(i, x, y) for(ll i=x; i<y; i++) #define FORNEG(i, x, y) for(ll i=x; i>y; i--) #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL) int min_cardinality(int N) { vector<ll> ins; vector<ll> outs; FOR(i,0,N){ move_inside(i); ll sus = press_button(); if (sus>1){ move_outside(i); outs.push_back(i); }else{ ins.push_back(i); } } ll numsize = ins.size(); ll lo = 1; ll hi = N/ins.size()+1; while (lo<hi){ int mid = lo + (hi - lo + 1) / 2; vector<ll> nowin; vector<ll> nowout; while (outs.size()){ ll sus = outs[outs.size()-1]; outs.pop_back(); move_inside(sus); ll count = press_button(); if (count>mid){ move_outside(sus); nowout.push_back(sus); }else{ nowin.push_back(sus); } if (ins.size() + nowin.size() == mid*numsize){ break; } } if (ins.size() + nowin.size() == mid*numsize){ for (auto&i : nowin){ ins.push_back(i); } for (auto&i : nowout){ outs.push_back(i); } lo = mid; }else{ for (auto&i : nowin){ move_outside(i); outs.push_back(i); } hi = mid-1; } } return lo; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:49:37: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   49 |       if (ins.size() + nowin.size() == mid*numsize){
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
insects.cpp:54:35: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   54 |     if (ins.size() + nowin.size() == mid*numsize){
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...