답안 #932551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932551 2024-02-23T15:32:07 Z velislavgarkov 드문 곤충 (IOI22_insects) C++17
0 / 100
37 ms 756 KB
#include "insects.h"
#include <iostream>
#include <vector>
using namespace std;
const int MAXN=1e4;
bool used[MAXN];
vector <int> last, removed;
int n, ss, d;
bool check(int x) {
    if (!last.empty()) last.clear();
    if (!removed.empty()) removed.clear();
    for (int i=0;i<n;i++) {
        if (used[i]) continue;
        move_inside(i);
        if (press_button()>x) {
            move_outside(i);
            removed.push_back(i);
        } else last.push_back(i);
    }
    if (ss+last.size()==d*x) return true;
    return false;
}
int min_cardinality(int N) {
    n=N;
    d=0;
    for (int i=0;i<n;i++) {
        move_inside(i);
        if (press_button()>1) move_outside(i);
        else {
            used[i]=true;
            d++;
        }
    }
    ss=d;
    int l, r, mid;
    l=1; r=n/d+1;
    while (l<r-1) {
        mid=(l+r)/2;
        if (check(mid)) {
            l=mid;
            ss+=last.size();
            for (auto i:last) used[i]=true;
        } else {
            r=mid-1;
            for (auto i:removed) used[i]=true;
            for (auto i:last) move_outside(i);
        }
    }
    //if (check(r)) return r;
    return l;
}

Compilation message

insects.cpp: In function 'bool check(int)':
insects.cpp:20:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if (ss+last.size()==d*x) return true;
      |         ~~~~~~~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Incorrect 3 ms 756 KB Wrong answer.
10 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 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Incorrect 3 ms 756 KB Wrong answer.
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 36 ms 436 KB Output is correct
8 Correct 9 ms 344 KB Output is correct
9 Correct 37 ms 420 KB Output is correct
10 Correct 23 ms 696 KB Output is correct
11 Correct 24 ms 680 KB Output is correct
12 Correct 15 ms 344 KB Output is correct
13 Incorrect 31 ms 600 KB Wrong answer.
14 Halted 0 ms 0 KB -