Submission #1024480

# Submission time Handle Problem Language Result Execution time Memory
1024480 2024-07-16T05:48:00 Z Otalp Rarest Insects (IOI22_insects) C++17
10 / 100
233 ms 1196 KB
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back


void put(int x){
    move_inside(x - 1);
}

void pop(int x){
    move_outside(x - 1);
}

int get(){
    return press_button();
}

int min_cardinality(int N) {
    int n = N;
    vector<int> d;
    map<int, int> q, cnt;
    int ls = 0;
    for(int i=1; i<=n; i++){
        put(i);
        //cout<<get()<<' '<<i<<'\n';
        if(get() == 1){
            q[i] = ++ls;
            cnt[ls] = 1;
            d.pb(i);
            continue;
        }
        for(int x: d){
            pop(x);
            if(get() == 1){
                cnt[q[x]] ++;
                q[i] = q[x];
            }
            put(x);
        }
        pop(i);
    }
    //for(int x: d) cout<<x<<' ';
    //cout<<'\n';
    int ans = -1, mn = 1e9;
    for(int i=1; i<=n; i++){
        //cout<<i<<' '<<q[i]<<'\n';
        if(cnt[q[i]] < mn){
            ans = i;
            mn = cnt[q[i]];
        }
    }
    return mn;
        
                
        
        
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:45:9: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   45 |     int ans = -1, mn = 1e9;
      |         ^~~
# Verdict Execution time Memory 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 0 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 11 ms 440 KB Output is correct
9 Correct 10 ms 600 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 30 ms 440 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 11 ms 344 KB Output is correct
14 Correct 5 ms 444 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 9 ms 344 KB Output is correct
17 Correct 15 ms 440 KB Output is correct
18 Correct 8 ms 596 KB Output is correct
19 Correct 22 ms 440 KB Output is correct
20 Correct 22 ms 420 KB Output is correct
21 Correct 47 ms 676 KB Output is correct
22 Correct 35 ms 424 KB Output is correct
# Verdict Execution time Memory 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 0 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 11 ms 440 KB Output is correct
9 Correct 10 ms 600 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 30 ms 440 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 11 ms 344 KB Output is correct
14 Correct 5 ms 444 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 9 ms 344 KB Output is correct
17 Correct 15 ms 440 KB Output is correct
18 Correct 8 ms 596 KB Output is correct
19 Correct 22 ms 440 KB Output is correct
20 Correct 22 ms 420 KB Output is correct
21 Correct 47 ms 676 KB Output is correct
22 Correct 35 ms 424 KB Output is correct
23 Correct 10 ms 696 KB Output is correct
24 Correct 5 ms 600 KB Output is correct
25 Correct 196 ms 596 KB Output is correct
26 Correct 167 ms 704 KB Output is correct
27 Correct 9 ms 344 KB Output is correct
28 Incorrect 217 ms 944 KB Too many queries.
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 18 ms 460 KB Output is correct
8 Correct 9 ms 600 KB Output is correct
9 Incorrect 233 ms 1196 KB Too many queries.
10 Halted 0 ms 0 KB -