Submission #658406

#TimeUsernameProblemLanguageResultExecution timeMemory
658406coding_snorlax드문 곤충 (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "insects.h"
using namespace std;
int All_type[200]={0};
int Box[200]={0};
int Check[200]={0};

int min_cardinality(int N){
    int level_1;
    for(int j=0;j<N;j++){
        int tmp;
        if(!All_type[j]){
            move_inside(j);
            tmp=press_button();
            if(tmp>i){
                move_outside(j);
            }
            else{
                Check[j]=1;
            }
        }
    }
    int Count=0;
    for(int j=0;j<N;j++){
        if(Check[j]==1) {
            move_outside(j);
            Check[j]=0;
            Count++;
        }
    }
    level_1=Count;
    //
    if(level_1>32){
        for(int i=2;i<=N;i++){
            for(int j=0;j<N;j++){
                int tmp;
                if(!All_type[j]){
                    move_inside(j);
                    tmp=press_button();
                    if(tmp>i){
                        move_outside(j);
                    }
                    else{
                        Check[j]=1;
                    }
                }
            }
            int Count=0;
            for(int j=0;j<N;j++){
                if(Check[j]==1) {
                    move_outside(j);
                    Check[j]=0;
                    Count++;
                }
            }
        else if(Count<level_1*i) return i-1;
        }
    return N;
    }
    else{
    int Count=1;
    for(int i=0;i<N;i++){
        int Now=0;
        for(int j=0;j<N;j++){
            int tmp;
            if(!All_type[j]){
                move_inside(j);
                tmp=press_button();
                if(tmp==Now){
                    move_outside(j);
                }
                else{
                    Check[j]=1;
                    Now++;
                }
            }
        }
        for(int j=0;j<N;j++){
            if(Check[j]==1) {
                move_outside(j);
                Check[j]=0;
                All_type[j]=Count;
            }
        }
        Count++;
    }
    int Min=2000;
    for(int i=1;i<=N;i++){
        int tmp=0;
        for(int j=0;j<N;j++){
            if(All_type[j]==i) tmp++;
        }
        if(tmp!=0) Min=min(tmp,Min);
    }
    return Min;
    }
}

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:15:20: error: 'i' was not declared in this scope
   15 |             if(tmp>i){
      |                    ^
insects.cpp:56:9: error: 'else' without a previous 'if'
   56 |         else if(Count<level_1*i) return i-1;
      |         ^~~~