Submission #1070730

#TimeUsernameProblemLanguageResultExecution timeMemory
1070730Mihailo드문 곤충 (IOI22_insects)C++17
62.52 / 100
118 ms956 KiB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pll pair<long long, long long>
#define MOD 1000002022ll
#define xx first
#define yy second
using namespace std;
typedef long long ll;

void move_inside(int i);
void move_outside(int i);
int press_button();

vector<int> rep;
set<int> setrep;
int tip[10000], bp[10000];

int min_cardinality(int N) {
    for(int i=0; i<N; i++) {
        move_inside(i);
        if(press_button()>1) move_outside(i);
        else {
            rep.pb(i);
            setrep.insert(i);
        }
    }
    if(rep.size()>N/2) return 1;
    if(rep.size()>N/8) {
        ll rez=1, cnt=rep.size();
        while(true) {
            for(int i=0; i<rep.size(); i++) move_outside(rep[i]);
            rep.clear();
            for(int i=0; i<N; i++) {
                if(!setrep.count(i)) {
                    move_inside(i);
                    if(press_button()>1) move_outside(i);
                    else {
                        rep.pb(i);
                        setrep.insert(i);
                    }
                }
            }
            if(rep.size()<cnt) return rez;
            rez++;
        }
    }
    for(int i=0; i<rep.size(); i++) tip[rep[i]]=i;
    for(int i=0; i<rep.size(); i++) {
        if(i%2==0) move_outside(rep[i]);
    }
    for(int i=0; i<N; i++) {
        if(!setrep.count(i)) {
            move_inside(i);
            if(press_button()==2) tip[i]+=1;
            move_outside(i);
        }
    }
    for(int b=1; b<7; b++) {
        for(int i=0; i<rep.size(); i++) {
            if((i&(1<<(b-1)))&&(!(i&(1<<(b))))) move_outside(rep[i]);
            if((!(i&(1<<(b-1))))&&(i&(1<<(b)))) move_inside(rep[i]);
        }
        for(int i=0; i<N; i++) {
            if(!setrep.count(i)) {
                move_inside(i);
                if(press_button()==2) tip[i]+=(1<<b);
                move_outside(i);
            }
        }
    }
    for(int i=0; i<N; i++) bp[tip[i]]++;
    for(int i=0; i<N; i++) if(tip[i]>=rep.size()) while(true);
    ll rez=MOD;
    for(int i=0; i<rep.size(); i++) rez=min(rez, (ll)bp[i]);
    return rez;
}














Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:28:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |     if(rep.size()>N/2) return 1;
      |        ~~~~~~~~~~^~~~
insects.cpp:29:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |     if(rep.size()>N/8) {
      |        ~~~~~~~~~~^~~~
insects.cpp:32:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |             for(int i=0; i<rep.size(); i++) move_outside(rep[i]);
      |                          ~^~~~~~~~~~~
insects.cpp:44:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   44 |             if(rep.size()<cnt) return rez;
      |                ~~~~~~~~~~^~~~
insects.cpp:48:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(int i=0; i<rep.size(); i++) tip[rep[i]]=i;
      |                  ~^~~~~~~~~~~
insects.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i=0; i<rep.size(); i++) {
      |                  ~^~~~~~~~~~~
insects.cpp:60:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         for(int i=0; i<rep.size(); i++) {
      |                      ~^~~~~~~~~~~
insects.cpp:73:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     for(int i=0; i<N; i++) if(tip[i]>=rep.size()) while(true);
      |                               ~~~~~~^~~~~~~~~~~~
insects.cpp:75:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |     for(int i=0; i<rep.size(); i++) rez=min(rez, (ll)bp[i]);
      |                  ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...