## Submission #215881

# Submission time Handle Problem Language Result Execution time Memory
215881 2020-03-26T12:05:58 Z emil_physmath The Big Prize (IOI17_prize) C++17
0 / 100
26 ms 11640 KB
```#include "prize.h"
#include <algorithm>
#include <iostream>
#include <chrono>
#include <random>
#include <vector>
using namespace std;
#ifdef MANSON
mt19937 rng(305);
#else
#endif // MANSON

namespace
{
const int maxN = 200000;
int n;

vector<int> cache[maxN];
{
if (cache[i].size()) return cache[i];
}
int mx = 0;
inline bool Cheapest(int i)
{
bool f = (res[0] + res[1] == mx);
// cerr << i << " is" << (f ? " " : "n't ") << " a cheapy.\n";
return f;
}
int Solve(int l, int r)
{
uniform_int_distribution<int> rnd(1, 2);
if (rnd(rng) == 1)
{
while (l <= r && !Cheapest(l))
{
if (res[0] + res[1] == 0) return l;
++l;
}
int len = 1;
for (int x = (1 << 17); x >= 1; x >>= 1)
{
int R = l + (len + x) - 1;
if (R > r) continue;
if (res1[1] == res2[1])
len += x;
}
if (l + len <= r)
return Solve(l + len, r);
return -1;
}
while (l <= r && !Cheapest(r))
{
if (res[0] + res[1] == 0) return l;
--r;
}
int len = 1;
for (int x = (1 << 17); x >= 1; x >>= 1)
{
int L = r - (len + x) + 1;
if (L > r) continue;
if (res1[1] == res2[1])
len += x;
}
if (l <= r - len)
return Solve(l, r - len);
return -1;
/*for (int len = 1; len <= r - l + 1; len *= 2)
while (l <= r && !Cheapest(r))
{
if (res[0] + res[1] == 0) return r;
--r;
}
if (l >= r) return -1;
if (res1[1] == res2[1]) return -1;
int m = (l + r) / 2;
int x = Solve(m + 1, r);
if (x != -1) return x;
return Solve(l, m);*/
}
}

int find_best(int n_) {
n = n_;
vector<int> p(n);
iota(p.begin(), p.end(), 0);
shuffle(p.begin(), p.end(), rng);
if (p.size() > 500) p.erase(p.begin() + 500, p.end());
for (int i: p)
{
mx = max(mx, res[0] + res[1]);
if (res[0] + res[1] == 0) return i;
}
return Solve(0, n - 1);
}
```

#### Subtask #1 0 / 20.0

# Verdict Execution time Memory Grader output
1 Correct 18 ms 5880 KB Output is correct
2 Runtime error 26 ms 11640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -

#### Subtask #2 0 / 80.0

# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 5876 KB Integer -1 violates the range [0, 199999]
2 Halted 0 ms 0 KB -