Submission #1072396

# Submission time Handle Problem Language Result Execution time Memory
1072396 2024-08-23T18:16:25 Z ewirlan Rarest Insects (IOI22_insects) C++17
100 / 100
45 ms 944 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> pr(n);
    iota(all(pr), 0);
    mt19937 mt(2137);
    shuffle(all(pr), mt);
    vector <int> v;
    vector <int> d;
    rep(i, 0, n){
        move_inside(pr[i]);
        if(press_button() > 1){
            move_outside(pr[i]);
            d.pb(i);
        }
        else v.pb(i);
    }
    int p(1), k(n/sz(v)), s;
    int r(sz(v));
    while(k > p){
        s = (p+k+1)/2;
        vector <int> w, e;
        bool b(1);
        for(auto i: d){
            move_inside(pr[i]);
            if(press_button() > s){
                move_outside(pr[i]);
                e.pb(i);
            } 
            else w.pb(i);
            if(sz(w)+sz(v) == s*r){
                p = s;
                for(auto i: w)v.pb(i);
                for(auto j: d)if(j > i)e.pb(j);
                d = e;
                b = 0;
                break;
            }
        }
        if(b){
            k = s-1;
            for(auto i: w)move_outside(pr[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 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 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 2 ms 440 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 3 ms 440 KB Output is correct
13 Correct 3 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 4 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 1 ms 440 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 1 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 2 ms 440 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 3 ms 440 KB Output is correct
13 Correct 3 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 4 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 1 ms 440 KB Output is correct
23 Correct 8 ms 856 KB Output is correct
24 Correct 5 ms 344 KB Output is correct
25 Correct 11 ms 600 KB Output is correct
26 Correct 10 ms 600 KB Output is correct
27 Correct 12 ms 600 KB Output is correct
28 Correct 7 ms 444 KB Output is correct
29 Correct 12 ms 344 KB Output is correct
30 Correct 12 ms 344 KB Output is correct
31 Correct 10 ms 604 KB Output is correct
32 Correct 11 ms 452 KB Output is correct
33 Correct 15 ms 592 KB Output is correct
34 Correct 13 ms 600 KB Output is correct
35 Correct 12 ms 452 KB Output is correct
36 Correct 14 ms 600 KB Output is correct
37 Correct 9 ms 592 KB Output is correct
38 Correct 14 ms 600 KB Output is correct
39 Correct 13 ms 448 KB Output is correct
40 Correct 9 ms 600 KB Output is correct
41 Correct 7 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 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 1 ms 344 KB Output is correct
7 Correct 26 ms 600 KB Output is correct
8 Correct 9 ms 344 KB Output is correct
9 Correct 33 ms 456 KB Output is correct
10 Correct 33 ms 448 KB Output is correct
11 Correct 20 ms 452 KB Output is correct
12 Correct 17 ms 452 KB Output is correct
13 Correct 32 ms 444 KB Output is correct
14 Correct 42 ms 448 KB Output is correct
15 Correct 30 ms 344 KB Output is correct
16 Correct 27 ms 600 KB Output is correct
17 Correct 22 ms 700 KB Output is correct
18 Correct 39 ms 452 KB Output is correct
19 Correct 25 ms 452 KB Output is correct
20 Correct 20 ms 456 KB Output is correct
21 Correct 35 ms 944 KB Output is correct
22 Correct 42 ms 600 KB Output is correct
23 Correct 22 ms 344 KB Output is correct
24 Correct 14 ms 344 KB Output is correct
25 Correct 20 ms 600 KB Output is correct
26 Correct 6 ms 344 KB Output is correct
27 Correct 17 ms 592 KB Output is correct
28 Correct 31 ms 608 KB Output is correct
29 Correct 14 ms 344 KB Output is correct
30 Correct 40 ms 452 KB Output is correct
31 Correct 26 ms 592 KB Output is correct
32 Correct 30 ms 436 KB Output is correct
33 Correct 24 ms 464 KB Output is correct
34 Correct 25 ms 344 KB Output is correct
35 Correct 23 ms 344 KB Output is correct
36 Correct 19 ms 452 KB Output is correct
37 Correct 45 ms 452 KB Output is correct
38 Correct 36 ms 448 KB Output is correct
39 Correct 25 ms 344 KB Output is correct
40 Correct 24 ms 608 KB Output is correct
41 Correct 28 ms 344 KB Output is correct
42 Correct 27 ms 600 KB Output is correct
43 Correct 6 ms 344 KB Output is correct
44 Correct 30 ms 440 KB Output is correct
45 Correct 25 ms 696 KB Output is correct
46 Correct 12 ms 344 KB Output is correct
47 Correct 16 ms 600 KB Output is correct
48 Correct 20 ms 600 KB Output is correct