#include "koala.h"
#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 1; (i) <= (n); ++i)
#define forn(i, l, r) for(int i = (l); i <= (r); ++i)
#define ford(i, r, l) for(int i = (r); i >= (l); --i)
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define FORD(i, n) for(int i = ((n) - 1); i >= 0; --i)
mt19937 rng(192929);
const int MaxN = 2e5 + 3;
int b[MaxN], r[MaxN];
int minValue(int N, int W) {
int x = rng() % N;
FOR(i, N) b[i] = 0;
b[x] = 1;
playRound(b, r);
int pos_x = 0;
while(r[pos_x]) ++pos_x;
if(r[x] == 2) return pos_x;
int y = rng() % N ;
b[x] = 0;
b[y] = 1;
playRound(b, r);
int pos_y;
while(r[pos_y]) ++pos_y;
if(r[y] == 2) return pos_y;
if(pos_x == pos_y) return pos_x;
return (rng() & 1) ? pos_x : pos_y;
}
int potential[MaxN];
int maxValue(int N, int W) {
FOR(i, N) potential[i] = 1;
while(true)
{
int cnt = 0;
FOR(i, N)
cnt += potential[i];
if(cnt == 1)
FOR(i, N) if(potential[i]) return i;
if(cnt == 0) assert(0);
FOR(i, N)
if(potential[i])
b[i] = W / cnt;
else b[i] = 0;
playRound(b, r);
FOR(i, N ) if(r[i] && potential[i]) potential[i] = 1;
else potential[i] = 0;
}
return 0;
}
int greaterValue(int N, int W) {
// TODO: Implement Subtask 3 solution here.
// You may leave this function unmodified if you are not attempting this
// subtask.
return 0;
}
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:39:18: warning: 'pos_y' may be used uninitialized in this function [-Wmaybe-uninitialized]
39 | while(r[pos_y]) ++pos_y;
| ~~~~~~~^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2392 KB |
Output is correct |
2 |
Correct |
3 ms |
2392 KB |
Output is correct |
3 |
Correct |
4 ms |
2544 KB |
Output is correct |
4 |
Correct |
5 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
2392 KB |
Output is correct |
2 |
Correct |
10 ms |
2392 KB |
Output is correct |
3 |
Correct |
11 ms |
2392 KB |
Output is correct |
4 |
Correct |
10 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |