제출 #629053

#제출 시각아이디문제언어결과실행 시간메모리
629053jhhope1드문 곤충 (IOI22_insects)C++17
95.36 / 100
85 ms556 KiB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
typedef long long ll;
int g;
int f(int h, int H, vector<int> V){
    if(H == h) return h;
    vector<int> O, I;
    for(int x: V){
        move_inside(x);
        if(press_button() == (h + H + 1) / 2 + 1){
            move_outside(x);
            O.push_back(x);
        }
        else{
            I.push_back(x);
        }
    }
    if(((H + h + 1) / 2 - h) * g == I.size()){
        return f((h + H + 1)/2, H, O);
    }
    for(int x: I){
        move_outside(x);
    }
    return f(h, (h + H + 1)/2 - 1, I);
}

int min_cardinality(int N) {
    move_inside(0);
    vector<int> V;
    for(int i=0 ; i<N ; i++){
        move_inside(i);
        if(press_button() == 2){
            move_outside(i);
            V.push_back(i);
        }
    }
    g = N - V.size();
    vector<int> W;
    for(int x: V){
        move_inside(x);
        if(press_button() > N/g){
            move_outside(x);
        }
        else{
            W.push_back(x);
        }
    }
    for(int x: W){
        move_outside(x);
    }
    return f(1, N/g, W);
}

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

insects.cpp: In function 'int f(int, int, std::vector<int>)':
insects.cpp:19:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     if(((H + h + 1) / 2 - h) * g == I.size()){
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...