제출 #726983

#제출 시각아이디문제언어결과실행 시간메모리
726983murad_2005드문 곤충 (IOI22_insects)C++17
99.95 / 100
71 ms472 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); inside[i] = false; } } } } return Res; }

컴파일 시 표준 에러 (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...