답안 #1070066

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1070066 2024-08-22T11:27:30 Z Unforgettablepl 드문 곤충 (IOI22_insects) C++17
0 / 100
74 ms 596 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);
    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;
            queries.emplace_back(ans[i]+jump,i);
        }
        int added = -1;
        sort(queries.begin(),queries.end());
        for(auto&[x,idx]:queries) {
            while(added<x)move_inside(uniques[++added]);
            while(added>x)move_outside(uniques[added--]);
            move_inside(idx);
            if(press_button()==1)ans[idx]=x;
            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:25: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]
   25 |             if(ans[i]+jump>=uniques.size()-1)continue;
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 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 2 ms 344 KB Output is correct
8 Incorrect 3 ms 596 KB Wrong answer.
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 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 2 ms 344 KB Output is correct
8 Incorrect 3 ms 596 KB Wrong answer.
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 12 ms 344 KB Output is correct
8 Correct 13 ms 460 KB Output is correct
9 Incorrect 74 ms 444 KB Wrong answer.
10 Halted 0 ms 0 KB -