답안 #824274

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824274 2023-08-13T22:57:11 Z boyliguanhan 드문 곤충 (IOI22_insects) C++17
0 / 100
1 ms 208 KB
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
int min_cardinality(int N) {
    vector<pair<int, int>> groups{{1,0}};
    for(int i = 1; i < N; i++) {
        int mv=1e9,mc;
        for(auto j:groups)
            if(j.first<mv)
                mv=j.first,mc=1;
            else if(j.first==mv)
                mc++;
        if(mc>N-i) {
            return mv;
        }
        vector<int> v;
        move_inside(i);
        for(auto i: groups)
            v.push_back(i.second), move_inside(i.second);
        int x = press_button();
        for(auto i: v)
            move_outside(i);
        if(x-1) {
            int l = 0, r = v.size()-1;
            while(l<r) {
                int mid = l+r>>1;
                for(int j = l; j <= mid; j++)
                    move_inside(v[i]);
                x = press_button();
                for(int j = l; j <= mid; j++)
                    move_outside(v[i]);
                if(x-1) {
                    r = mid;
                } else {
                    l = mid+1;
                }
            }
            groups[l].first++;
        } else
            groups.push_back({1,i});
        move_outside(i);
    }
    return min_element(groups.begin(), groups.end())->first;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:26:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |                 int mid = l+r>>1;
      |                           ~^~
insects.cpp:12:19: warning: 'mc' may be used uninitialized in this function [-Wmaybe-uninitialized]
   12 |                 mc++;
      |                 ~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Incorrect 0 ms 208 KB Integer 4113 violates the range [0, 7]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Incorrect 0 ms 208 KB Integer 4113 violates the range [0, 7]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Incorrect 0 ms 208 KB Integer 4113 violates the range [0, 9]
7 Halted 0 ms 0 KB -