제출 #1229636

#제출 시각아이디문제언어결과실행 시간메모리
1229636SpyrosAlivMonster Game (JOI21_monster)C++20
10 / 100
59 ms408 KiB
#include "monster.h"
#include <bits/stdc++.h>
using namespace std;

int n;

vector<int> Solve(int N) {
    n = N;
    vector<int> a(n, -1);
    vector<int> loss(n, 0), win(n, 0);
    int idxa = -1, idxb = -1;
    int i2 = -1, j2 = -1;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int ans = Query(i, j);
            if (ans == true) {
                win[i]++;
                loss[j]++;
            }
            else {
                loss[i]++;
                win[j]++;
            }
        }
        a[i] = abs(loss[i] - n) - 1;
        if (a[i] == 1) {
            if (idxa == -1) idxa = i;
            else idxb = i;
        }
        if (a[i] == n-2) {
            if (i2 == -1) i2 = i;
            else j2 = i;
        }
    }
    int ans = Query(idxa, idxb);
    if (ans) {
        a[idxa] = 0;
    }
    else a[idxb] = 0;
    ans = Query(i2, j2);
    if (ans) {
        a[j2] = n-1;
    }
    else a[i2] = n-1;
    return a;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...