Submission #830907

#TimeUsernameProblemLanguageResultExecution timeMemory
830907tolbiRarest Insects (IOI22_insects)C++17
0 / 100
14 ms312 KiB
#include <bits/stdc++.h> using namespace std; mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count()); #include "insects.h" int min_cardinality(int n) { function<int(int)> f; set<int> olan; for (int i = 0; i < n; ++i) { olan.insert(i); } vector<int> kullandim; vector<int> kullanmadim; f = [&](int x)->int{ int ans = 0; vector<int> crr; for (auto it : olan){ crr.push_back(it); move_inside(it); if (press_button()>x){ crr.pop_back(); kullanmadim.push_back(it); move_outside(it); } else kullandim.push_back(it),ans++; } for (int i = 0; i < crr.size(); ++i) { move_outside(crr[i]); } return ans; }; int diff = f(1); kullanmadim.clear(); kullandim.clear(); if (diff==1) return n; int l = 1, r = n; int hueh = 0; while (l<r){ int mid = l+(r-l+1)/2; int hayda = f(mid); //cout<<l<<" "<<r<<" "<<mid<<" "<<hayda<<" "<<hueh<<endl; if (hayda+hueh<(mid*diff)){ r=mid-1; for (auto &it : kullanmadim){ olan.erase(it); } } else { l = mid; hueh+=hayda; for (auto &it : kullandim){ olan.erase(it); } } kullandim.clear(); kullanmadim.clear(); } return l; }

Compilation message (stderr)

insects.cpp: In lambda function:
insects.cpp:27:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for (int i = 0; i < crr.size(); ++i)
      |                         ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...