Submission #1024478

# Submission time Handle Problem Language Result Execution time Memory
1024478 2024-07-16T05:47:39 Z vjudge1 Rarest Insects (IOI22_insects) C++17
10 / 100
250 ms 704 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 0 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 13 ms 436 KB Output is correct
9 Correct 12 ms 604 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 27 ms 600 KB Output is correct
12 Correct 6 ms 600 KB Output is correct
13 Correct 17 ms 440 KB Output is correct
14 Correct 6 ms 344 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 9 ms 600 KB Output is correct
17 Correct 10 ms 344 KB Output is correct
18 Correct 10 ms 344 KB Output is correct
19 Correct 16 ms 436 KB Output is correct
20 Correct 31 ms 600 KB Output is correct
21 Correct 54 ms 344 KB Output is correct
22 Correct 43 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 13 ms 436 KB Output is correct
9 Correct 12 ms 604 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 27 ms 600 KB Output is correct
12 Correct 6 ms 600 KB Output is correct
13 Correct 17 ms 440 KB Output is correct
14 Correct 6 ms 344 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 9 ms 600 KB Output is correct
17 Correct 10 ms 344 KB Output is correct
18 Correct 10 ms 344 KB Output is correct
19 Correct 16 ms 436 KB Output is correct
20 Correct 31 ms 600 KB Output is correct
21 Correct 54 ms 344 KB Output is correct
22 Correct 43 ms 600 KB Output is correct
23 Correct 7 ms 344 KB Output is correct
24 Correct 4 ms 344 KB Output is correct
25 Correct 192 ms 448 KB Output is correct
26 Correct 188 ms 704 KB Output is correct
27 Correct 18 ms 460 KB Output is correct
28 Incorrect 250 ms 700 KB Too many queries.
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 12 ms 344 KB Output is correct
8 Correct 10 ms 600 KB Output is correct
9 Incorrect 208 ms 696 KB Too many queries.
10 Halted 0 ms 0 KB -