Submission #59594

# Submission time Handle Problem Language Result Execution time Memory
59594 2018-07-22T15:18:38 Z duality Koala Game (APIO17_koala) C++11
61 / 100
143 ms 972 KB
#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;
    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;
    else if ((R[a] > 0) && (R[b] > 0)) {
        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;
        for (i = 0; i < N; i++) B[i] = 0;
        B[a] = B[b] = 8;
        playRound(B,R);
        if ((R[a] > 0) != (R[b] > 0)) return R[b] > 0;
    }
    else {
        for (i = 0; i < N; i++) B[i] = 0;
        B[a] = B[b] = 1;
        playRound(B,R);
        if ((R[a] > 0) != (R[b] > 0)) return R[b] > 0;
    }
    return -1;
}
int greaterValue(int N,int W) {
    return compare(0,1,N,W);
}

int n,w;
int inv[100],temp[100];
int mergesort(int *arr,int l,int r) {
    if (l == r) return 0;
    int m = (l+r) / 2;
    mergesort(arr,l,m),mergesort(arr,m+1,r);
    int i = l,j = m+1,k = 0;
    while ((i <= m) || (j <= r)) {
        if (i > m) temp[k++] = arr[j++];
        else if (j > r) temp[k++] = arr[i++];
        else if (compare(arr[i],arr[j],n,w)) temp[k++] = arr[i++];
        else temp[k++] = arr[j++];
    }
    for (i = 0; i < k; i++) arr[l+i] = temp[i];
    return 0;
}
void allValues(int N,int W,int *P) {
    n = N,w = W;
    if (W == 2*N) {
        // TODO: Implement Subtask 4 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    } else {
        int i;
        for (i = 0; i < N; i++) inv[i] = i;
        random_shuffle(inv,inv+N);
        mergesort(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 9 ms 380 KB Output is correct
2 Correct 9 ms 488 KB Output is correct
3 Correct 9 ms 488 KB Output is correct
4 Correct 7 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 532 KB Output is correct
2 Correct 17 ms 640 KB Output is correct
3 Correct 20 ms 780 KB Output is correct
4 Correct 21 ms 780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 800 KB Output is correct
2 Correct 89 ms 808 KB Output is correct
3 Correct 134 ms 808 KB Output is correct
4 Correct 92 ms 856 KB Output is correct
5 Correct 86 ms 972 KB Output is correct
6 Correct 78 ms 972 KB Output is correct
7 Correct 88 ms 972 KB Output is correct
8 Correct 143 ms 972 KB Output is correct
9 Correct 94 ms 972 KB Output is correct
10 Correct 81 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 66 ms 972 KB Output is partially correct
2 Partially correct 44 ms 972 KB Output is partially correct
3 Partially correct 44 ms 972 KB Output is partially correct
4 Partially correct 45 ms 972 KB Output is partially correct
5 Partially correct 47 ms 972 KB Output is partially correct
6 Partially correct 48 ms 972 KB Output is partially correct
7 Partially correct 46 ms 972 KB Output is partially correct
8 Partially correct 54 ms 972 KB Output is partially correct
9 Partially correct 38 ms 972 KB Output is partially correct
10 Partially correct 61 ms 972 KB Output is partially correct
11 Partially correct 47 ms 972 KB Output is partially correct
12 Partially correct 45 ms 972 KB Output is partially correct
13 Partially correct 44 ms 972 KB Output is partially correct
14 Partially correct 63 ms 972 KB Output is partially correct
15 Partially correct 43 ms 972 KB Output is partially correct
16 Partially correct 51 ms 972 KB Output is partially correct
17 Partially correct 42 ms 972 KB Output is partially correct
18 Partially correct 48 ms 972 KB Output is partially correct
19 Partially correct 63 ms 972 KB Output is partially correct
20 Partially correct 47 ms 972 KB Output is partially correct
21 Partially correct 45 ms 972 KB Output is partially correct
22 Partially correct 44 ms 972 KB Output is partially correct
23 Partially correct 58 ms 972 KB Output is partially correct
24 Partially correct 40 ms 972 KB Output is partially correct
25 Partially correct 45 ms 972 KB Output is partially correct
26 Partially correct 38 ms 972 KB Output is partially correct
27 Partially correct 43 ms 972 KB Output is partially correct
28 Partially correct 48 ms 972 KB Output is partially correct
29 Partially correct 51 ms 972 KB Output is partially correct
30 Partially correct 40 ms 972 KB Output is partially correct
31 Partially correct 56 ms 972 KB Output is partially correct
32 Partially correct 40 ms 972 KB Output is partially correct
33 Partially correct 49 ms 972 KB Output is partially correct
34 Partially correct 44 ms 972 KB Output is partially correct
35 Partially correct 46 ms 972 KB Output is partially correct
36 Partially correct 45 ms 972 KB Output is partially correct
37 Partially correct 46 ms 972 KB Output is partially correct
38 Partially correct 42 ms 972 KB Output is partially correct
39 Partially correct 44 ms 972 KB Output is partially correct
40 Partially correct 52 ms 972 KB Output is partially correct