답안 #975006

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975006 2024-05-04T09:32:28 Z pirhosig 드문 곤충 (IOI22_insects) C++17
0 / 100
31 ms 1480 KB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
    
    
    
int min_cardinality(int N) {
    unordered_set<int> rem;
    
    for (int i = 0; i < N; ++i) {
        move_inside(i);
        if (press_button() > 1) {
            move_outside(i);
            rem.insert(i);
        }
    }
    int T = N - rem.size();
    
    int low = 1;
    int upp = N / T;
    while (low < upp) {
        int mid = (low + upp + 1) / 2;
        vector<int> curr;
        int cnt = 0;
        for (int a : rem) {
            cnt++;
            move_inside(a);
            if (press_button() > mid) move_outside(a);
            else curr.push_back(a);

            if ((mid - low) * T - (int)curr.size() > (int)rem.size() - cnt) break;
        }
    
        if (curr.size() == (mid - low) * T) {
            low = mid;
            for (int a : curr) rem.erase(a);
        }
        else {
            upp = mid - 1;
            rem.clear();
            for (int a : curr) {
                move_outside(a);
                rem.insert(a);
            }
        }
    }
    
    return low;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:34:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |         if (curr.size() == (mid - low) * T) {
      |             ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Incorrect 2 ms 600 KB Wrong answer.
13 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 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Incorrect 2 ms 600 KB Wrong answer.
13 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 0 ms 344 KB Output is correct
7 Correct 31 ms 888 KB Output is correct
8 Correct 10 ms 344 KB Output is correct
9 Correct 27 ms 1392 KB Output is correct
10 Correct 24 ms 1112 KB Output is correct
11 Correct 19 ms 1164 KB Output is correct
12 Correct 10 ms 1124 KB Output is correct
13 Correct 28 ms 908 KB Output is correct
14 Correct 27 ms 1480 KB Output is correct
15 Correct 28 ms 988 KB Output is correct
16 Incorrect 29 ms 892 KB Wrong answer.
17 Halted 0 ms 0 KB -