답안 #1070091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1070091 2024-08-22T11:37:34 Z Unforgettablepl 드문 곤충 (IOI22_insects) C++17
0 / 100
2000 ms 1032 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

int min_cardinality(int N){
    vector<int> uniques = {0};
    move_inside(0);
    vector<bool> isCommon(N);
    vector<int> ans(N,-1);
    ans[0]=1;
    for(int i=1;i<N;i++) {
        move_inside(i);
        if(press_button()==1) {
            uniques.emplace_back(i);
            ans[i]=1;
        } else {
            move_outside(i);
            isCommon[i]=true;
        }
    }
    for(int&i:uniques)move_outside(i);
    int added = -1;
    for(int jump=1024;jump;jump/=2) {
        vector<pair<int,int>> queries;
        for(int i=0;i<N;i++)if(isCommon[i]) {
            if(ans[i]+jump>=uniques.size()-1)continue;
            if((ans[i]+1)&(jump<<1))continue;
            queries.emplace_back(ans[i]+jump,i);
        }
        sort(queries.begin(),queries.end());
        for(int i=0;i<queries.size();i++) {
            auto [x,idx] = queries[i];
            while(added<x)move_inside(uniques[++added]);
            while(added>x)move_outside(uniques[added--]);
            move_inside(idx);
            if(press_button()==1) {
                ans[idx]=x;
                int y = x+1;
                queries.emplace_back(x+((y&-y)>>1),idx);
                sort(queries.begin(), queries.end());
            }
            move_outside(idx);
        }
    }
    for(int i=0;i<N;i++)if(isCommon[i])ans[uniques[ans[i]+1]]++;
    int siz = N;
    for(int i=0;i<N;i++)if(!isCommon[i])siz=min(siz,ans[i]);
    return siz;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:26:27: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             if(ans[i]+jump>=uniques.size()-1)continue;
insects.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i=0;i<queries.size();i++) {
      |                     ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Execution timed out 3064 ms 1032 KB Time limit exceeded
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 Execution timed out 3064 ms 1032 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Execution timed out 3027 ms 912 KB Time limit exceeded
5 Halted 0 ms 0 KB -