Submission #1055662

# Submission time Handle Problem Language Result Execution time Memory
1055662 2024-08-13T02:43:39 Z thieunguyenhuy The Big Prize (IOI17_prize) C++17
20 / 100
42 ms 596 KB
#ifndef hwe
	#include "prize.h"
#endif

#include <bits/stdc++.h>
using namespace std;

#define popcount(n) (__builtin_popcountll((n)))
#define clz(n) (__builtin_clzll((n)))
#define ctz(n) (__builtin_ctzll((n)))
#define lg(n) (63 - __builtin_clzll((n)))
#define BIT(n, i) (((n) >> (i)) & 1ll)
#define MASK(i) (1ll << (i))
#define FLIP(n, i) ((n) ^ (1ll << (i)))
#define ON(n, i) ((n) | MASK(i))
#define OFF(n, i) ((n) & ~MASK(i))

#define Int __int128
#define fi first
#define se second

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long, long long>> vll;
typedef vector<pair<long long, int>> vli;
typedef vector<pair<int, long long>> vil;

template <class T1, class T2>
bool maximize(T1 &x, T2 y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
template <class T1, class T2>
bool minimize(T1 &x, T2 y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template <class T>
void remove_duplicate(vector<T> &ve) {
    sort (ve.begin(), ve.end());
    ve.resize(unique(ve.begin(), ve.end()) - ve.begin());
}

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
template <class T> T random(T l, T r) {
    return uniform_int_distribution<T>(l, r)(rng);
}
template <class T> T random(T r) {
    return rng() % r;
}

const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;

map<int, vector<int>> mem;
int ans = -1, not_lolipop = 0;

#ifdef hwe
vector<int> ask(int id) {

}
#endif

vector<int> myask(int id) {
    auto it = mem.find(id);
    if (it != mem.end()) return mem[id];
    return ask(id);
}

void dnc(int l, int r, int prefL, int prefR) {
    if (ans != -1) return;
    if (prefR - prefL == 0) return;
    
    if (l == r) {
        vector<int> tmp = myask(l);
        if (tmp[0] + tmp[1] == 0) ans = l;
        return;
    }

    int mid = l + r + 1 >> 1; vector<int> ask_mid = myask(mid);

    dnc(l, mid - 1, prefL, ask_mid[0]);
    dnc(mid, r, ask_mid[0], prefR);
}

int find_best(int n) {
    ans = not_lolipop = -1;
    for (int i = 0; i < 500; ++i) {
        vector<int> tmp = myask(i);
        maximize(not_lolipop, tmp[0] + tmp[1]);
    }

    dnc(0, n - 1, 0, not_lolipop);
    return ans;
}

#ifdef hwe
signed main() {
    

    cerr << '\n'; return 0;
}
#endif

Compilation message

prize.cpp: In function 'void dnc(int, int, int, int)':
prize.cpp:95:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   95 |     int mid = l + r + 1 >> 1; vector<int> ask_mid = myask(mid);
      |               ~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 428 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 2 ms 432 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 6 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 Partially correct 20 ms 344 KB Partially correct - number of queries: 5520
17 Correct 2 ms 344 KB Output is correct
18 Partially correct 24 ms 432 KB Partially correct - number of queries: 6538
19 Correct 2 ms 344 KB Output is correct
20 Correct 9 ms 344 KB Output is correct
21 Correct 10 ms 344 KB Output is correct
22 Correct 5 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 3 ms 344 KB Output is correct
25 Correct 21 ms 344 KB Output is correct
26 Correct 12 ms 344 KB Output is correct
27 Correct 4 ms 344 KB Output is correct
28 Partially correct 28 ms 344 KB Partially correct - number of queries: 5791
29 Correct 16 ms 344 KB Output is correct
30 Partially correct 42 ms 344 KB Partially correct - number of queries: 6489
31 Correct 2 ms 344 KB Output is correct
32 Correct 4 ms 344 KB Output is correct
33 Incorrect 1 ms 344 KB Integer 100 violates the range [0, 99]
34 Halted 0 ms 0 KB -