# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
111817 |
2019-05-16T09:33:07 Z |
dndhk |
Koala Game (APIO17_koala) |
C++14 |
|
114 ms |
892 KB |
#include "koala.h"
#include <algorithm>
#include <vector>
#define pb push_back
using namespace std;
int B[100], R[100];
int minValue(int N, int W) {
B[99] = 1;
playRound(B, R);
for(int i=0; i<N; i++){
if(R[i]==0){
return i;
}
}
return 99;
}
int maxValue(int N, int W) {
for(int i=0; i<N; i++){
B[i] = 1;
}
playRound(B, R);
for(int i=0; i<N; i++){
if(R[i]==2){
B[i] = 2;
}else{
B[i] = 0;
}
}
playRound(B, R);
int cnt = 25;
for(int i=0; i<N; i++){
if(R[i]>=3){
B[i] = 3;
}else if(B[i]!=0 && cnt>0){
B[i] = 1;
cnt--;
}else B[i] = 0;
}
playRound(B, R);
for(int i=0; i<N; i++){
if(R[i]>=4){
B[i] = 13;
}else B[i] = 0;
}
playRound(B, R);
for(int i=0; i<N; i++){
if(R[i]>=14){
return i;
}
}
return -1;
}
int chk(int x){
B[0] = B[1] = x;
playRound(B, R);
if(R[0]>x && R[1]>x){
return 2;
}else if(R[0]<=x && R[1]<=x){
return 3;
}else{
if(R[0]>R[1]) return 0;
return 1;
}
}
int greaterValue(int N, int W) {
int t = chk(3);
if(t==0) return 0;
if(t==1) return 1;
if(t==2){
t = chk(5);
if(t==0) return 0;
if(t==1) return 1;
if(t==2){
t = chk(8);
if(t==0) return 0;
return 1;
}
}else{
t = chk(2);
if(t==0) return 0;
if(t==1) return 1;
if(t==3){
t = chk(1);
if(t==0) return 0;
return 1;
}
}
return -1;
}
int xx, yy;
int chk2(int k){
B[xx] = B[yy] = k;
playRound(B, R);
B[xx] = B[yy] = 0;
if(R[xx]>k && R[yy]>k){
return 2;
}else if(R[xx]<=k && R[yy]<=k){
return 3;
}else{
if(R[xx]>R[yy]) return 0;
return 1;
}
}
bool sf2(int x, int y){
xx = x; yy = y;
int t = chk2(3);
if(t==0) return 0;
if(t==1) return 1;
if(t==2){
t = chk2(5);
if(t==0) return 0;
if(t==1) return 1;
if(t==2){
t = chk2(8);
if(t==0) return 0;
return 1;
}
}else{
t = chk2(2);
if(t==0) return 0;
if(t==1) return 1;
if(t==3){
t = chk2(1);
if(t==0) return 0;
return 1;
}
}
return -1;
}
int n;
bool sf(int x, int y){
B[x] = B[y] = 100;
playRound(B, R);
B[x] = B[y] = 0;
if(R[x]>R[y]) return 1;
return 0;
}
int arr[100];
vector<int> v;
void srt(int x, int y){
if(x==y) return;
int m = (x+y)/2;
srt(x, m); srt(m+1, y);
int i1 = x, i2 = m+1;
while(!v.empty()) v.pop_back();
while(i1<=m || i2<=y){
if(i1>m){
v.pb(arr[i2++]);
}else if(i2>y){
v.pb(arr[i1++]);
}else{
bool t = sf(arr[i1], arr[i2]);
if(t){
v.pb(arr[i2++]);
}else{
v.pb(arr[i1++]);
}
}
}
for(int i=0; i<v.size(); i++){
arr[i+x] = v[i];
}
return;
}
void srt2(int x, int y){
if(x==y) return;
int m = (x+y)/2;
srt2(x, m); srt2(m+1, y);
int i1 = x, i2 = m+1;
while(!v.empty()) v.pop_back();
while(i1<=m || i2<=y){
if(i1>m){
v.pb(arr[i2++]);
}else if(i2>y){
v.pb(arr[i1++]);
}else{
bool t = sf2(arr[i1], arr[i2]);
if(!t){
v.pb(arr[i2++]);
}else{
v.pb(arr[i1++]);
}
}
}
for(int i=0; i<v.size(); i++){
arr[i+x] = v[i];
}
return;
}
void allValues(int N, int W, int *P) {
if (W == 2*N) {
n = N;
for(int i=0; i<N; i++){
arr[i] = i;
}
srt(0, N-1);
for(int i=0; i<N; i++){
P[arr[i]] = i+1;
}
} else {
n = N;
for(int i=0; i<N; i++){
arr[i] = i;
}
srt2(0, N-1);
for(int i=0; i<N; i++){
P[arr[i]] = i+1;
}
}
}
Compilation message
koala.cpp: In function 'void srt(int, int)':
koala.cpp:176:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<v.size(); i++){
~^~~~~~~~~
koala.cpp: In function 'void srt2(int, int)':
koala.cpp:203:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<v.size(); i++){
~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
372 KB |
Output is correct |
2 |
Correct |
7 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
256 KB |
Output is correct |
2 |
Correct |
14 ms |
384 KB |
Output is correct |
3 |
Correct |
18 ms |
384 KB |
Output is correct |
4 |
Correct |
16 ms |
392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
520 KB |
Output is correct |
2 |
Correct |
101 ms |
676 KB |
Output is correct |
3 |
Correct |
74 ms |
760 KB |
Output is correct |
4 |
Correct |
78 ms |
716 KB |
Output is correct |
5 |
Correct |
87 ms |
640 KB |
Output is correct |
6 |
Correct |
71 ms |
640 KB |
Output is correct |
7 |
Correct |
114 ms |
760 KB |
Output is correct |
8 |
Correct |
74 ms |
632 KB |
Output is correct |
9 |
Correct |
81 ms |
632 KB |
Output is correct |
10 |
Correct |
78 ms |
892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
256 KB |
Output is correct |
2 |
Correct |
33 ms |
256 KB |
Output is correct |
3 |
Correct |
35 ms |
256 KB |
Output is correct |
4 |
Correct |
34 ms |
256 KB |
Output is correct |
5 |
Correct |
31 ms |
384 KB |
Output is correct |
6 |
Correct |
31 ms |
384 KB |
Output is correct |
7 |
Correct |
28 ms |
376 KB |
Output is correct |
8 |
Correct |
32 ms |
256 KB |
Output is correct |
9 |
Correct |
34 ms |
256 KB |
Output is correct |
10 |
Correct |
36 ms |
384 KB |
Output is correct |
11 |
Correct |
31 ms |
512 KB |
Output is correct |
12 |
Correct |
19 ms |
256 KB |
Output is correct |
13 |
Correct |
31 ms |
384 KB |
Output is correct |
14 |
Correct |
29 ms |
476 KB |
Output is correct |
15 |
Correct |
39 ms |
384 KB |
Output is correct |
16 |
Correct |
38 ms |
384 KB |
Output is correct |
17 |
Correct |
24 ms |
256 KB |
Output is correct |
18 |
Correct |
28 ms |
536 KB |
Output is correct |
19 |
Correct |
32 ms |
376 KB |
Output is correct |
20 |
Correct |
42 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
20 ms |
256 KB |
Output is partially correct |
2 |
Partially correct |
62 ms |
384 KB |
Output is partially correct |
3 |
Partially correct |
55 ms |
256 KB |
Output is partially correct |
4 |
Partially correct |
37 ms |
504 KB |
Output is partially correct |
5 |
Partially correct |
38 ms |
256 KB |
Output is partially correct |
6 |
Partially correct |
39 ms |
384 KB |
Output is partially correct |
7 |
Partially correct |
44 ms |
364 KB |
Output is partially correct |
8 |
Partially correct |
38 ms |
256 KB |
Output is partially correct |
9 |
Partially correct |
39 ms |
368 KB |
Output is partially correct |
10 |
Partially correct |
40 ms |
368 KB |
Output is partially correct |
11 |
Partially correct |
37 ms |
256 KB |
Output is partially correct |
12 |
Partially correct |
21 ms |
364 KB |
Output is partially correct |
13 |
Partially correct |
36 ms |
256 KB |
Output is partially correct |
14 |
Partially correct |
36 ms |
376 KB |
Output is partially correct |
15 |
Partially correct |
38 ms |
256 KB |
Output is partially correct |
16 |
Partially correct |
38 ms |
256 KB |
Output is partially correct |
17 |
Partially correct |
33 ms |
256 KB |
Output is partially correct |
18 |
Partially correct |
48 ms |
256 KB |
Output is partially correct |
19 |
Partially correct |
36 ms |
384 KB |
Output is partially correct |
20 |
Partially correct |
33 ms |
256 KB |
Output is partially correct |
21 |
Partially correct |
32 ms |
256 KB |
Output is partially correct |
22 |
Partially correct |
35 ms |
384 KB |
Output is partially correct |
23 |
Partially correct |
30 ms |
384 KB |
Output is partially correct |
24 |
Partially correct |
34 ms |
400 KB |
Output is partially correct |
25 |
Partially correct |
31 ms |
256 KB |
Output is partially correct |
26 |
Partially correct |
40 ms |
384 KB |
Output is partially correct |
27 |
Partially correct |
34 ms |
256 KB |
Output is partially correct |
28 |
Partially correct |
33 ms |
364 KB |
Output is partially correct |
29 |
Partially correct |
45 ms |
376 KB |
Output is partially correct |
30 |
Partially correct |
36 ms |
384 KB |
Output is partially correct |
31 |
Partially correct |
34 ms |
376 KB |
Output is partially correct |
32 |
Partially correct |
33 ms |
256 KB |
Output is partially correct |
33 |
Partially correct |
38 ms |
256 KB |
Output is partially correct |
34 |
Partially correct |
35 ms |
256 KB |
Output is partially correct |
35 |
Partially correct |
38 ms |
372 KB |
Output is partially correct |
36 |
Partially correct |
36 ms |
504 KB |
Output is partially correct |
37 |
Partially correct |
34 ms |
256 KB |
Output is partially correct |
38 |
Partially correct |
47 ms |
384 KB |
Output is partially correct |
39 |
Partially correct |
34 ms |
256 KB |
Output is partially correct |
40 |
Partially correct |
36 ms |
364 KB |
Output is partially correct |