답안 #1025186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1025186 2024-07-16T17:12:52 Z Wansur 드문 곤충 (IOI22_insects) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
#define ent '\n'

void move_inside(int i);
void move_outside(int i);
int press_button();

using namespace std;
typedef long long ll;
const int maxn = 1e5 + 12;

bool used[maxn];
vector<int> d;
int n, m, c, cnt = 0;

bool check(int x){
    x -= cnt;
    vector<int> a, b;
    for(int i=0;i<n;i++){
        if(used[i]) continue;
        move_inside(i);
        if(press_button() > x){
            move_outside(i);
            b.push_back(i);
        }
        else a.push_back(i);
    }
    if(a.size() == x * m){
        return 1;
    }
    return 0;
}

int min_cardinality(int N){
    n = N;
    c = n;
    for(int i=0;i<n;i++){
        move_inside(i);
        if(press_button() != 1){
            move_outside(i);
        }
        else d.push_back(i);
    }
    for(int i:d){
        move_outside(i);
    }
    m = d.size();
    int ans = 0;
    for(int l = 1, r = n; l <= r;){
        int mid = l + r >> 1;
        if(check(mid)){
            ans = mid;
            l = mid + 1;
        }
        else r = mid - 1;
    }
    return ans;
}

Compilation message

insects.cpp: In function 'bool check(int)':
insects.cpp:28:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |     if(a.size() == x * m){
      |        ~~~~~~~~~^~~~~~~~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:50:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   50 |         int mid = l + r >> 1;
      |                   ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Wrong answer.
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Wrong answer.
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -