#ifndef CHEISSMART
#include "koala.h"
#endif
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
cerr << to_string(h);
if(sizeof ...(t)) cerr << ", ";
DBG(t...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif
const int INF = 1e9 + 7;
int a[100], b[100];
int minValue(int N, int W) {
for(int i = 0; i < N; i++)
a[i] = 1;
playRound(a, b);
int k;
for(int j = 0; j < N; j++)
if(b[j] == 2)
k = j;
for(int i = 0; i < N; i++)
a[i] = 0;
a[k] = 1;
playRound(a, b);
for(int i = 0; i < N; i++)
if(b[i] == 0)
return i;
}
int maxValue(int N, int W) {
set<int> s;
for(int i = 0; i < N; i++)
s.insert(i);
while(s.size() > 1) {
int x = s.size();
for(int i = 0; i < N; i++) {
if(s.count(i)) {
a[i] = W / x;
} else {
a[i] = 0;
}
}
s.clear();
playRound(a, b);
for(int i = 0; i < N; i++)
if(b[i] == W / x + 1)
s.insert(i);
}
return *s.begin();
}
int greaterValue(int N, int W) {
int mn = minValue(N, W);
if(mn == 0) return 1;
else if(mn == 1) return 0;
int lb = 1, rb = W / 2;
while(true) {
for(int i = 0; i < N; i++)
a[i] = 0;
int mb = (lb + rb) / 2;
debug(lb, mb, rb);
a[0] = a[1] = mb;
playRound(a, b);
if(b[0] > a[0] && b[1] <= a[1])
return 0;
if(b[1] > a[1] && b[0] <= a[0])
return 1;
if(b[0] > a[0] && b[1] > a[1])
lb = mb + 1;
else
rb = mb - 1;
}
}
void allValues(int N, int W, int *P) {
if (W == 2*N) {
// TODO: Implement Subtask 4 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
} else {
// TODO: Implement Subtask 5 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
}
}
Compilation message
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
52 | }
| ^
koala.cpp:47:10: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
47 | a[k] = 1;
| ~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
200 KB |
Output is correct |
2 |
Correct |
10 ms |
200 KB |
Output is correct |
3 |
Correct |
8 ms |
200 KB |
Output is correct |
4 |
Correct |
8 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
320 KB |
Output is correct |
2 |
Correct |
17 ms |
200 KB |
Output is correct |
3 |
Correct |
17 ms |
316 KB |
Output is correct |
4 |
Correct |
20 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
171 ms |
320 KB |
Output is partially correct |
2 |
Partially correct |
155 ms |
200 KB |
Output is partially correct |
3 |
Partially correct |
189 ms |
320 KB |
Output is partially correct |
4 |
Partially correct |
173 ms |
460 KB |
Output is partially correct |
5 |
Partially correct |
172 ms |
320 KB |
Output is partially correct |
6 |
Partially correct |
169 ms |
304 KB |
Output is partially correct |
7 |
Partially correct |
169 ms |
312 KB |
Output is partially correct |
8 |
Partially correct |
168 ms |
316 KB |
Output is partially correct |
9 |
Partially correct |
164 ms |
308 KB |
Output is partially correct |
10 |
Partially correct |
169 ms |
312 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |