답안 #1062458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062458 2024-08-17T07:17:56 Z ewirlan 드문 곤충 (IOI22_insects) C++17
99.89 / 100
41 ms 852 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 r(sz(v));
    if(r*5 >= n){
        vector <int> e;
        rep(i, 2, 7){
            e.clear();
            for(auto j: d){
                move_inside(j);
                if(press_button() > i){
                    move_outside(j);
                    e.pb(j);
                }
                else v.pb(j);
            }
            if(sz(v) != i*r)return i-1;
            d = e;
        }
    }
    int p(1), k(n/r), s;
    // 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 = (sz(w)+sz(v))/r;
            for(auto i: w)move_outside(i);
            d = w;
        }
    }
    return p;
}
# 결과 실행 시간 메모리 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 3 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 4 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 3 ms 344 KB Output is correct
19 Correct 4 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
# 결과 실행 시간 메모리 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 3 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 4 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 3 ms 344 KB Output is correct
19 Correct 4 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 16 ms 600 KB Output is correct
24 Correct 6 ms 344 KB Output is correct
25 Correct 13 ms 444 KB Output is correct
26 Correct 12 ms 344 KB Output is correct
27 Correct 7 ms 344 KB Output is correct
28 Correct 12 ms 344 KB Output is correct
29 Correct 14 ms 344 KB Output is correct
30 Correct 14 ms 596 KB Output is correct
31 Correct 17 ms 444 KB Output is correct
32 Correct 10 ms 344 KB Output is correct
33 Correct 16 ms 600 KB Output is correct
34 Correct 11 ms 600 KB Output is correct
35 Correct 19 ms 440 KB Output is correct
36 Correct 13 ms 344 KB Output is correct
37 Correct 17 ms 600 KB Output is correct
38 Correct 12 ms 600 KB Output is correct
39 Correct 8 ms 344 KB Output is correct
40 Correct 7 ms 444 KB Output is correct
41 Correct 6 ms 344 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 40 ms 600 KB Output is correct
8 Correct 11 ms 344 KB Output is correct
9 Correct 29 ms 684 KB Output is correct
10 Correct 39 ms 600 KB Output is correct
11 Correct 18 ms 440 KB Output is correct
12 Correct 11 ms 340 KB Output is correct
13 Correct 25 ms 344 KB Output is correct
14 Correct 24 ms 600 KB Output is correct
15 Correct 25 ms 432 KB Output is correct
16 Correct 27 ms 424 KB Output is correct
17 Correct 20 ms 596 KB Output is correct
18 Correct 26 ms 688 KB Output is correct
19 Partially correct 35 ms 680 KB Output is partially correct
20 Correct 29 ms 448 KB Output is correct
21 Correct 32 ms 448 KB Output is correct
22 Correct 37 ms 448 KB Output is correct
23 Correct 23 ms 344 KB Output is correct
24 Correct 18 ms 344 KB Output is correct
25 Correct 20 ms 344 KB Output is correct
26 Correct 12 ms 596 KB Output is correct
27 Correct 21 ms 600 KB Output is correct
28 Correct 24 ms 344 KB Output is correct
29 Partially correct 31 ms 592 KB Output is partially correct
30 Partially correct 30 ms 344 KB Output is partially correct
31 Correct 26 ms 592 KB Output is correct
32 Correct 26 ms 688 KB Output is correct
33 Correct 22 ms 592 KB Output is correct
34 Correct 25 ms 444 KB Output is correct
35 Partially correct 40 ms 600 KB Output is partially correct
36 Partially correct 25 ms 432 KB Output is partially correct
37 Correct 22 ms 692 KB Output is correct
38 Correct 31 ms 852 KB Output is correct
39 Correct 29 ms 424 KB Output is correct
40 Correct 35 ms 592 KB Output is correct
41 Partially correct 28 ms 592 KB Output is partially correct
42 Partially correct 26 ms 344 KB Output is partially correct
43 Correct 7 ms 600 KB Output is correct
44 Correct 18 ms 444 KB Output is correct
45 Correct 41 ms 684 KB Output is correct
46 Correct 11 ms 344 KB Output is correct
47 Correct 13 ms 600 KB Output is correct
48 Correct 13 ms 344 KB Output is correct