답안 #859267

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
859267 2023-10-10T02:53:45 Z kim 드문 곤충 (IOI22_insects) C++17
0 / 100
1 ms 344 KB
#include "insects.h"
#include<bits/stdc++.h>

using namespace std;

#define in move_inside
#define press press_button
#define out move_outside

vector<int> vec0;
set<int> mp;
int p;
int n;
stack<int> st;
int k0;

bool check(int k1){
    stack<int> st;
    for(int i=1;i<=n;++i){
        if(mp.count(i)) continue;
        in(i);
        if(press()>k1) out(i);
        else mp.insert(i),st.push(i);
    }
    if(mp.size()==p*k1){
        k0=k1;
        return 1;
    }
    while(st.size()){
        mp.erase(st.top());
        out(st.top());
        st.pop();
    }
    return 0;
}

int min_cardinality(int N){
    n=N;
    for(int i=0;i<n;++i){
        in(i), vec0.push_back(i);
        if(press()>1) out(i),vec0.pop_back();
    }
    p=vec0.size();
    for(auto &e:vec0) mp.insert(e); //out(e);
    k0=1;

    int l=1,r=n/p;
    while(l<r){
        int mid=l+(r-l+1>>1);
        if(check(mid)) l=mid;
        else r=mid-1;
    }
    return l;
}

Compilation message

insects.cpp: In function 'bool check(int)':
insects.cpp:25:17: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     if(mp.size()==p*k1){
      |        ~~~~~~~~~^~~~~~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:49:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   49 |         int mid=l+(r-l+1>>1);
      |                    ~~~^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Integer 6 violates the range [0, 5]
2 Halted 0 ms 0 KB -