Submission #1062240

# Submission time Handle Problem Language Result Execution time Memory
1062240 2024-08-16T22:33:45 Z ewirlan Rarest Insects (IOI22_insects) C++17
99.89 / 100
39 ms 864 KB
//
#ifndef __SIZEOF_INT128__
  #define __SIZEOF_INT128__
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template <typename T> using oset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i, p, k) for(int i(p); i < (k); ++i)
#define per(i, p, k) for(int i(p); i > (k); --i)
#define sz(x) (int)(x).size()
#define sc static_cast
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef __int128_t lll;
//#define int ll
template <typename T = int> using par = std::pair <T, T>;
#define fi first
#define se second
#define test int _number_of_tests(in()); while(_number_of_tests--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb emplace_back
struct Timer {
    string name{""};
    time_point<high_resolution_clock> end, start{high_resolution_clock::now()};
    duration<float, std::milli> dur;
    Timer() = default;
    Timer(string nm): name(nm) {}
    ~Timer() {
        end = high_resolution_clock::now(); dur= end - start;
        cout << "@" << name << "> " << dur.count() << " ms" << '\n';
    }
};
template <typename T = int> inline T in()
{
    static T x;
    std::cin >> x;
    return x;
}
std::string yn(bool b)
{
    if(b) return "YES\n";
    else return "NO\n";
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par);
template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector <T>& wek)
{
    for(const auto& i : wek)out << i << ' ';
    return out;
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par)
{
    out << '{'<<par.first<<", "<<par.second<<"}";
    return out;
}
#define show(x) cerr << #x << " = " << x << '\n';
#include "insects.h"
int min_cardinality(int n)
{
    vector <int> v;
    vector <int> d;
    rep(i, 0, n){
        move_inside(i);
        if(press_button() > 1){
            move_outside(i);
            d.pb(i);
        }
        else v.pb(i);
    }
    int p(1), k(n/sz(v)), s;
    int r(sz(v));
    // cerr << v << " | " << d << '\n';
    while(k > p){
        // cerr << d << ":\n";
        s = (p+k+1)/2;
        vector <int> w, e;
        for(auto i: d){
            move_inside(i);
            if(press_button() > s){
                move_outside(i);
                e.pb(i);
            } 
            else w.pb(i);
        }
        // cerr << s << ": " << w << " | " << e << '\n';
        if(sz(w)+sz(v) == s*r){
            p = s;
            for(auto i: w)v.pb(i);
            d = e;
        }
        else{
            k = s-1;
            for(auto i: w)move_outside(i);
            d = w;
        }
    }
    return p;
}
# 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 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 3 ms 340 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 ms 420 KB Output is correct
9 Correct 4 ms 344 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 4 ms 344 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 3 ms 344 KB Output is correct
16 Correct 4 ms 344 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 1 ms 344 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 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 3 ms 340 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 ms 420 KB Output is correct
9 Correct 4 ms 344 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 4 ms 344 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 3 ms 344 KB Output is correct
16 Correct 4 ms 344 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 18 ms 440 KB Output is correct
24 Correct 5 ms 344 KB Output is correct
25 Correct 17 ms 604 KB Output is correct
26 Correct 21 ms 596 KB Output is correct
27 Correct 9 ms 344 KB Output is correct
28 Correct 5 ms 344 KB Output is correct
29 Correct 13 ms 444 KB Output is correct
30 Correct 16 ms 444 KB Output is correct
31 Correct 13 ms 344 KB Output is correct
32 Correct 13 ms 344 KB Output is correct
33 Correct 17 ms 596 KB Output is correct
34 Correct 13 ms 344 KB Output is correct
35 Correct 16 ms 436 KB Output is correct
36 Correct 19 ms 344 KB Output is correct
37 Correct 12 ms 344 KB Output is correct
38 Correct 19 ms 696 KB Output is correct
39 Correct 8 ms 600 KB Output is correct
40 Correct 5 ms 856 KB Output is correct
41 Correct 6 ms 344 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 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 0 ms 344 KB Output is correct
7 Correct 31 ms 688 KB Output is correct
8 Correct 10 ms 600 KB Output is correct
9 Correct 25 ms 432 KB Output is correct
10 Correct 25 ms 592 KB Output is correct
11 Correct 26 ms 344 KB Output is correct
12 Correct 21 ms 344 KB Output is correct
13 Correct 27 ms 704 KB Output is correct
14 Correct 31 ms 592 KB Output is correct
15 Correct 26 ms 344 KB Output is correct
16 Correct 32 ms 604 KB Output is correct
17 Correct 23 ms 344 KB Output is correct
18 Correct 28 ms 600 KB Output is correct
19 Partially correct 27 ms 864 KB Output is partially correct
20 Correct 26 ms 592 KB Output is correct
21 Correct 36 ms 596 KB Output is correct
22 Correct 37 ms 592 KB Output is correct
23 Correct 23 ms 448 KB Output is correct
24 Correct 21 ms 344 KB Output is correct
25 Correct 11 ms 444 KB Output is correct
26 Correct 12 ms 604 KB Output is correct
27 Correct 29 ms 444 KB Output is correct
28 Correct 17 ms 344 KB Output is correct
29 Partially correct 28 ms 344 KB Output is partially correct
30 Partially correct 30 ms 676 KB Output is partially correct
31 Correct 37 ms 344 KB Output is correct
32 Correct 34 ms 440 KB Output is correct
33 Correct 17 ms 444 KB Output is correct
34 Correct 39 ms 600 KB Output is correct
35 Partially correct 33 ms 444 KB Output is partially correct
36 Partially correct 35 ms 848 KB Output is partially correct
37 Correct 20 ms 344 KB Output is correct
38 Correct 27 ms 684 KB Output is correct
39 Correct 28 ms 692 KB Output is correct
40 Correct 26 ms 428 KB Output is correct
41 Partially correct 33 ms 600 KB Output is partially correct
42 Partially correct 30 ms 600 KB Output is partially correct
43 Correct 6 ms 344 KB Output is correct
44 Correct 22 ms 436 KB Output is correct
45 Correct 28 ms 428 KB Output is correct
46 Correct 15 ms 344 KB Output is correct
47 Correct 13 ms 600 KB Output is correct
48 Correct 21 ms 452 KB Output is correct