Submission #1181256

#TimeUsernameProblemLanguageResultExecution timeMemory
1181256KerimGame (IOI14_game)C++17
0 / 100
0 ms328 KiB
#include "game.h"
#include <algorithm>
using namespace std;
int a[3], b[3];

int C(int x){
    return x * (x-1) / 2;
}

void initialize(int n) {
    for (int i = 0; i < 3; i++) {
        a[i] = 0;
    }
    int z = (n+1)/2, o = n/2;
    b[0] = C(z);
    b[1] = C(o);
    b[2] = z * o;
}

int hasEdge(int u, int v) {
    if (u > v)
        swap(u, v);
    int t = 2;
    if (u%2 == 0 and v%2 == 0)
        t = 0;
    if (u%2 == 1 and v%2 == 1)
        t = 1;
    int resp;
    // 0: no
    // 1: yes
    if (a[t] < b[t]){
        a[t]++;
        if (t < 2)
            resp = 1;
        else
            resp = 0;
    }
    else{
        if (t < 2)
            resp = 0;
        else
            resp = 1;
    }
    return resp;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...