// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>
#include "koala.h"
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int n, w;
int minValue(int N, int W) {
int me[N], you[N];
for (int i = 0; i < N; ++i) {
me[i] = 0;
}
me[0] = 1;
playRound(me, you);
int i = 0;
while (you[i]) {
++i;
}
return i;
}
int maxValue(int N, int W) {
int me[N], you[N];
vector<int> v;
for (int i = 0; i < N; ++i) {
v.pb(i);
}
while (v.size() > 1) {
int sz = v.size();
int k = (W + sz) / sz - 1;
fill(me, me + N, 0);
// v.size() > k
for (int x : v) {
me[x] = k;
}
playRound(me, you);
vector<int> nv;
for (int x : v) {
if (you[x] > me[x]) {
nv.pb(x);
}
}
assert(!nv.empty());
v = nv;
}
return v[0];
}
bool cmp(int a, int b) {
int me[n] = {}, you[n];
int L = 1, R = 8;
while (L <= R) {
int x = (L + R) >> 1;
me[a] = me[b] = x;
playRound(me, you);
if (you[a] != you[b]) {
if (you[a] > you[b]) {
return 0;
}
else {
return 1;
}
}
if (you[a] > 0) {
L = x + 1;
}
else {
R = x - 1;
}
}
}
bool cmp2(int a, int b) {
int me[n] = {}, you[n];
me[a] = me[b] = n;
playRound(me, you);
return you[b] > me[b];
}
int greaterValue(int N, int W) {
n = N;
w = W;
return cmp(0, 1) ? 1 : 0;
}
vector<int> mysort(vector<int> v) {
if (v.size() <= 1) {
return v;
}
int m = (v.size() - 1) / 2;
vector<int> a, b;
for (int i = 0; i < v.size(); ++i) {
if (i <= m) {
a.pb(v[i]);
}
else {
b.pb(v[i]);
}
}
a = mysort(a);
b = mysort(b);
vector<int> ret;
int ptr = 0;
for (int id : a) {
while (ptr < b.size() && cmp(b[ptr], id)) {
ret.pb(b[ptr++]);
}
ret.pb(id);
}
while (ptr < b.size()) {
ret.pb(b[ptr++]);
}
return ret;
}
vector<int> solve(vector<int> v) {
//stable_sort(all(v), cmp);
//return v;
if (v.size() <= 1) {
return v;
}
int me[n] = {}, you[n];
int k = w / v.size();
for (int x : v) {
me[x] = k;
}
playRound(me, you);
vector<int> a, b;
for (int x : v) {
if (you[x] > 0) {
b.pb(x);
}
else {
a.pb(x);
}
}
if (a.empty() || b.empty()) {
return mysort(v);
}
a = solve(a);
b = solve(b);
for (int x : b) {
a.pb(x);
}
return a;
}
void allValues(int N, int W, int *P) {
n = N;
w = W;
vector<int> v;
for (int i = 0; i < n; ++i) {
v.pb(i);
}
if (w == 2 * n) {
stable_sort(all(v), cmp2);
}
else {
v = solve(v);
}
for (int i = 0; i < v.size(); ++i) {
P[v[i]] = i + 1;
}
}
Compilation message
koala.cpp: In function 'std::vector<int> mysort(std::vector<int>)':
koala.cpp:128:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size(); ++i) {
~~^~~~~~~~~~
koala.cpp:143:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (ptr < b.size() && cmp(b[ptr], id)) {
~~~~^~~~~~~~~~
koala.cpp:150:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (ptr < b.size()) {
~~~~^~~~~~~~~~
koala.cpp: In function 'void allValues(int, int, int*)':
koala.cpp:214:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size(); ++i) {
~~^~~~~~~~~~
koala.cpp: In function 'bool cmp(int, int)':
koala.cpp:105:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
248 KB |
Output is correct |
2 |
Correct |
10 ms |
252 KB |
Output is correct |
3 |
Correct |
10 ms |
376 KB |
Output is correct |
4 |
Correct |
10 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
248 KB |
Output is correct |
2 |
Correct |
22 ms |
248 KB |
Output is correct |
3 |
Correct |
23 ms |
248 KB |
Output is correct |
4 |
Correct |
21 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
96 ms |
376 KB |
Output is partially correct |
2 |
Partially correct |
113 ms |
592 KB |
Output is partially correct |
3 |
Partially correct |
91 ms |
248 KB |
Output is partially correct |
4 |
Partially correct |
95 ms |
248 KB |
Output is partially correct |
5 |
Partially correct |
97 ms |
248 KB |
Output is partially correct |
6 |
Partially correct |
94 ms |
248 KB |
Output is partially correct |
7 |
Partially correct |
96 ms |
248 KB |
Output is partially correct |
8 |
Partially correct |
94 ms |
248 KB |
Output is partially correct |
9 |
Partially correct |
92 ms |
468 KB |
Output is partially correct |
10 |
Partially correct |
89 ms |
248 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
332 KB |
Output is correct |
2 |
Correct |
55 ms |
248 KB |
Output is correct |
3 |
Correct |
54 ms |
248 KB |
Output is correct |
4 |
Correct |
55 ms |
428 KB |
Output is correct |
5 |
Correct |
54 ms |
248 KB |
Output is correct |
6 |
Correct |
53 ms |
376 KB |
Output is correct |
7 |
Correct |
53 ms |
332 KB |
Output is correct |
8 |
Correct |
53 ms |
248 KB |
Output is correct |
9 |
Correct |
54 ms |
248 KB |
Output is correct |
10 |
Correct |
52 ms |
376 KB |
Output is correct |
11 |
Correct |
55 ms |
248 KB |
Output is correct |
12 |
Correct |
26 ms |
248 KB |
Output is correct |
13 |
Correct |
52 ms |
248 KB |
Output is correct |
14 |
Correct |
48 ms |
248 KB |
Output is correct |
15 |
Correct |
47 ms |
248 KB |
Output is correct |
16 |
Correct |
50 ms |
504 KB |
Output is correct |
17 |
Correct |
51 ms |
376 KB |
Output is correct |
18 |
Correct |
48 ms |
380 KB |
Output is correct |
19 |
Correct |
50 ms |
248 KB |
Output is correct |
20 |
Correct |
49 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
16 ms |
344 KB |
Output is partially correct |
2 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
3 |
Partially correct |
17 ms |
248 KB |
Output is partially correct |
4 |
Partially correct |
19 ms |
380 KB |
Output is partially correct |
5 |
Partially correct |
16 ms |
380 KB |
Output is partially correct |
6 |
Partially correct |
17 ms |
248 KB |
Output is partially correct |
7 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
8 |
Partially correct |
15 ms |
248 KB |
Output is partially correct |
9 |
Partially correct |
17 ms |
248 KB |
Output is partially correct |
10 |
Partially correct |
16 ms |
376 KB |
Output is partially correct |
11 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
12 |
Partially correct |
13 ms |
248 KB |
Output is partially correct |
13 |
Partially correct |
16 ms |
376 KB |
Output is partially correct |
14 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
15 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
16 |
Partially correct |
17 ms |
344 KB |
Output is partially correct |
17 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
18 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
19 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
20 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
21 |
Partially correct |
17 ms |
248 KB |
Output is partially correct |
22 |
Partially correct |
17 ms |
248 KB |
Output is partially correct |
23 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
24 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
25 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
26 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
27 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
28 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
29 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
30 |
Partially correct |
17 ms |
248 KB |
Output is partially correct |
31 |
Partially correct |
17 ms |
248 KB |
Output is partially correct |
32 |
Partially correct |
16 ms |
376 KB |
Output is partially correct |
33 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
34 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
35 |
Partially correct |
15 ms |
248 KB |
Output is partially correct |
36 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
37 |
Partially correct |
16 ms |
376 KB |
Output is partially correct |
38 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
39 |
Partially correct |
16 ms |
248 KB |
Output is partially correct |
40 |
Partially correct |
17 ms |
376 KB |
Output is partially correct |