#include "koala.h"
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <cassert>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include <numeric>
using namespace std;
const int NMAX = 1000 + 7;
int nglob;
int b[NMAX];
int r[NMAX];
int wn[NMAX];
int isbig[NMAX];
void print(int a[])
{
cout << " ---> ";
for (int i = 0; i < nglob; i++)
{
cout << a[i] << " ";
}
cout << "\n";
}
void ask()
{
playRound(b, r);
for (int i = 0; i < nglob; i++)
{
wn[i] = (r[i] > b[i]);
}
}
int minValue(int n, int w)
{
nglob = n;
assert(n < NMAX);
assert(w < NMAX);
assert(n == w);
assert(n % 2 == 0);
for (int i = 0; i < n; i++)
{
b[i] = 0;
}
b[3] = 1;
ask();
int cnt_lose = 0;
for (int i = 0; i < n; i++)
{
cnt_lose += (wn[i] == 0);
}
assert(cnt_lose == 1);
for (int i = 0; i < n; i++)
{
if (wn[i] == 0)
{
return i;
}
}
assert(0);
}
int maxValue(int n, int w)
{
nglob = n;
assert(n < NMAX);
assert(w < NMAX);
assert(n == w);
assert(n % 2 == 0);
for (int i = 0; i < n; i++)
{
isbig[i] = 1;
}
for (auto& val : { 1, 2, 4, 11 })
{
for (int i = 0; i < n; i++)
{
b[i] = 0;
if (isbig[i])
{
b[i] = val;
}
}
ask();
for (int i = 0; i < n; i++)
{
isbig[i] &= wn[i];
}
}
int cntbig = 0;
for (int i = 0; i < n; i++)
{
cntbig += isbig[i];
}
assert(cntbig == 1);
for (int i = 0; i < n; i++)
{
if (isbig[i])
{
return i;
}
}
assert(0);
}
int greaterValue(int n, int w)
{
nglob = n;
assert(n < NMAX);
assert(w < NMAX);
vector<int> v;
for (int i = 1; i <= 50; i++)
{
v.push_back(i);
}
v = { 1, 2, 4, 8, 16, 32 };
int low = 0, high = (int)v.size() - 1;
while (low <= high)
{
int mid = (low + high) / 2;
int val = v[mid];
for (int i = 0; i < n; i++)
{
b[i] = 0;
}
b[0] = b[1] = val;
ask();
if (wn[0] && wn[1])
{
low = mid + 1;
continue;
}
if (!wn[0] && !wn[1])
{
high = mid - 1;
continue;
}
if (wn[0] && !wn[1]) return 0;
assert(wn[1] && !wn[0]);
return 1;
}
assert(0);
}
void allValues(int n, int w, int* p)
{
nglob = n;
assert(n < NMAX);
assert(w < NMAX);
if (w == 2 * n)
{
// TODO: Implement Subtask 4 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
}
else
{
//cout << "salut!\n";
assert(w == n);
// TODO: Implement Subtask 5 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
336 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
3 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
208 KB |
Output is correct |
2 |
Correct |
11 ms |
208 KB |
Output is correct |
3 |
Correct |
11 ms |
208 KB |
Output is correct |
4 |
Correct |
10 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
340 KB |
Output is correct |
2 |
Correct |
68 ms |
340 KB |
Output is correct |
3 |
Correct |
62 ms |
336 KB |
Output is correct |
4 |
Correct |
64 ms |
332 KB |
Output is correct |
5 |
Correct |
62 ms |
336 KB |
Output is correct |
6 |
Correct |
62 ms |
344 KB |
Output is correct |
7 |
Correct |
62 ms |
336 KB |
Output is correct |
8 |
Correct |
62 ms |
336 KB |
Output is correct |
9 |
Correct |
64 ms |
352 KB |
Output is correct |
10 |
Correct |
63 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |