#define DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}
// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
public:
template<typename T>
_Debug& operator,(T val) {
cout << val << endl;
return *this;
}
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif
// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back
// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;
// ---------- END OF TEMPLATE ----------
#include "koala.h"
int B[100],R[100];
int minValue(int N,int W) {
int i;
for (i = 0; i < N; i++) B[i] = 0;
B[0] = 1;
playRound(B,R);
for (i = 0; i < N; i++) {
if (R[i] == 0) return i;
}
return 0;
}
int maxValue(int N,int W) {
int i;
for (i = 0; i < N; i++) B[i] = 1;
playRound(B,R);
for (i = 0; i < N; i++) {
if (R[i] == 2) B[i] = 2;
else B[i] = 0;
}
playRound(B,R);
for (i = 0; i < N; i++) {
if (R[i] == 3) B[i] = 4;
else B[i] = 0;
}
playRound(B,R);
for (i = 0; i < N; i++) {
if (R[i] == 5) B[i] = 11;
else B[i] = 0;
}
playRound(B,R);
for (i = 0; i < N; i++) {
if (R[i] == 12) return i;
}
}
int compare(int a,int b,int N,int W) {
int i;
if (W == 2*N) {
for (i = 0; i < N; i++) B[i] = 0;
B[a] = B[b] = N;
playRound(B,R);
return R[a] < R[b];
}
for (i = 0; i < N; i++) B[i] = 0;
B[a] = B[b] = 6;
playRound(B,R);
if ((R[a] > 0) != (R[b] > 0)) return R[b] > 0;
else if ((R[a] == 0) && (R[b] == 0)) {
for (i = 0; i < N; i++) B[i] = 0;
B[a] = B[b] = 3;
playRound(B,R);
if ((R[a] > 0) != (R[b] > 0)) return R[b] > 0;
for (i = 0; i < N; i++) B[i] = 0;
B[a] = B[b] = 1;
playRound(B,R);
return R[b] > 0;
}
else {
for (i = 0; i < N; i++) B[i] = 0;
B[a] = B[b] = 8;
playRound(B,R);
return R[b] > 0;
}
}
int greaterValue(int N,int W) {
return compare(0,1,N,W);
}
int n,w;
int inv[100],temp[100];
int mysort(int *arr,int l,int r) {
if (l == r) return 0;
int i,j;
for (i = 0; i < n; i++) B[i] = 0;
int val = 1,e = r-l+1;
for (i = 1; i <= w/(r-l+1); i++) {
int m1 = 0,m2 = 0,ne = r-l+1;
for (j = 0; j <= n-(r-l+1); j++) {
int x = min((w-j)/(i+1),r-l+1);
int sum = (2*n-min(j,n-r-1)+1)*min(j,n-r-1)/2;
sum += (2*l-(j-min(j,n-r-1))+1)*(j-min(j,n-r-1))/2;
sum += (2*r-x+3)*x/2;
if ((sum > m1) || ((sum == m1) && (j+x > m2))) {
m1 = sum,m2 = j+x;
ne = max(x,r-l+1-x);
}
}
if (ne < e) e = ne,val = i;
}
for (i = l; i <= r; i++) B[arr[i]] = val;
playRound(B,R);
j = 0;
for (i = l; i <= r; i++) {
if (R[arr[i]] <= B[arr[i]]) temp[j++] = arr[i];
}
int m = j;
for (i = l; i <= r; i++) {
if (R[arr[i]] > B[arr[i]]) temp[j++] = arr[i];
}
for (i = l; i <= r; i++) arr[i] = temp[i-l];
mysort(arr,l,l+m-1),mysort(arr,l+m,r);
return 0;
}
void allValues(int N,int W,int *P) {
n = N,w = W;
int i;
for (i = 0; i < N; i++) inv[i] = i;
mysort(inv,0,N-1);
for (i = 0; i < N; i++) P[inv[i]] = i+1;
}
Compilation message
koala.cpp: In function 'int maxValue(int, int)':
koala.cpp:93:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
248 KB |
Output is correct |
2 |
Correct |
10 ms |
356 KB |
Output is correct |
3 |
Correct |
10 ms |
576 KB |
Output is correct |
4 |
Correct |
12 ms |
576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
612 KB |
Output is correct |
2 |
Correct |
24 ms |
656 KB |
Output is correct |
3 |
Correct |
29 ms |
656 KB |
Output is correct |
4 |
Correct |
25 ms |
656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
748 KB |
Output is correct |
2 |
Correct |
93 ms |
840 KB |
Output is correct |
3 |
Correct |
83 ms |
880 KB |
Output is correct |
4 |
Correct |
61 ms |
880 KB |
Output is correct |
5 |
Correct |
64 ms |
880 KB |
Output is correct |
6 |
Correct |
65 ms |
880 KB |
Output is correct |
7 |
Correct |
76 ms |
880 KB |
Output is correct |
8 |
Correct |
70 ms |
880 KB |
Output is correct |
9 |
Correct |
74 ms |
880 KB |
Output is correct |
10 |
Correct |
64 ms |
880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
880 KB |
Output is correct |
2 |
Correct |
15 ms |
880 KB |
Output is correct |
3 |
Correct |
20 ms |
880 KB |
Output is correct |
4 |
Correct |
15 ms |
880 KB |
Output is correct |
5 |
Correct |
14 ms |
880 KB |
Output is correct |
6 |
Correct |
16 ms |
880 KB |
Output is correct |
7 |
Correct |
14 ms |
880 KB |
Output is correct |
8 |
Correct |
15 ms |
880 KB |
Output is correct |
9 |
Correct |
17 ms |
880 KB |
Output is correct |
10 |
Correct |
17 ms |
880 KB |
Output is correct |
11 |
Correct |
15 ms |
880 KB |
Output is correct |
12 |
Correct |
21 ms |
880 KB |
Output is correct |
13 |
Correct |
16 ms |
880 KB |
Output is correct |
14 |
Correct |
15 ms |
880 KB |
Output is correct |
15 |
Correct |
18 ms |
880 KB |
Output is correct |
16 |
Correct |
23 ms |
880 KB |
Output is correct |
17 |
Correct |
17 ms |
880 KB |
Output is correct |
18 |
Correct |
16 ms |
880 KB |
Output is correct |
19 |
Correct |
13 ms |
880 KB |
Output is correct |
20 |
Correct |
17 ms |
880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
880 KB |
Output is correct |
2 |
Correct |
13 ms |
880 KB |
Output is correct |
3 |
Correct |
8 ms |
880 KB |
Output is correct |
4 |
Correct |
10 ms |
880 KB |
Output is correct |
5 |
Correct |
10 ms |
880 KB |
Output is correct |
6 |
Correct |
10 ms |
880 KB |
Output is correct |
7 |
Correct |
10 ms |
880 KB |
Output is correct |
8 |
Correct |
9 ms |
880 KB |
Output is correct |
9 |
Correct |
8 ms |
880 KB |
Output is correct |
10 |
Correct |
9 ms |
880 KB |
Output is correct |
11 |
Correct |
9 ms |
880 KB |
Output is correct |
12 |
Correct |
9 ms |
880 KB |
Output is correct |
13 |
Correct |
9 ms |
880 KB |
Output is correct |
14 |
Correct |
11 ms |
880 KB |
Output is correct |
15 |
Correct |
11 ms |
880 KB |
Output is correct |
16 |
Correct |
10 ms |
880 KB |
Output is correct |
17 |
Correct |
10 ms |
880 KB |
Output is correct |
18 |
Correct |
10 ms |
880 KB |
Output is correct |
19 |
Correct |
11 ms |
880 KB |
Output is correct |
20 |
Correct |
12 ms |
880 KB |
Output is correct |
21 |
Correct |
12 ms |
880 KB |
Output is correct |
22 |
Correct |
9 ms |
880 KB |
Output is correct |
23 |
Correct |
10 ms |
880 KB |
Output is correct |
24 |
Correct |
12 ms |
880 KB |
Output is correct |
25 |
Correct |
8 ms |
880 KB |
Output is correct |
26 |
Correct |
8 ms |
880 KB |
Output is correct |
27 |
Correct |
11 ms |
880 KB |
Output is correct |
28 |
Correct |
10 ms |
880 KB |
Output is correct |
29 |
Correct |
13 ms |
880 KB |
Output is correct |
30 |
Correct |
10 ms |
880 KB |
Output is correct |
31 |
Correct |
12 ms |
880 KB |
Output is correct |
32 |
Correct |
8 ms |
880 KB |
Output is correct |
33 |
Correct |
13 ms |
880 KB |
Output is correct |
34 |
Correct |
12 ms |
880 KB |
Output is correct |
35 |
Correct |
13 ms |
880 KB |
Output is correct |
36 |
Correct |
11 ms |
880 KB |
Output is correct |
37 |
Correct |
9 ms |
880 KB |
Output is correct |
38 |
Correct |
9 ms |
880 KB |
Output is correct |
39 |
Correct |
9 ms |
880 KB |
Output is correct |
40 |
Correct |
10 ms |
880 KB |
Output is correct |