제출 #1349525

#제출 시각아이디문제언어결과실행 시간메모리
1349525ramzialoulouMonster Game (JOI21_monster)C++20
10 / 100
42 ms4256 KiB
#include <bits/stdc++.h>
#include "monster.h"

using namespace std;

const int N = 1009;
int win[N][N];

std::vector<int> Solve(int N) {
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      win[i][j] = Query(i, j);
      win[j][i] = win[i][j] ^ 1;
    }
  }
  vector<int> cnt(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cnt[i] += win[i][j];
    }
  }
  vector<int> T(N, -1);
  for (int i = 0; i < N; i++) {
    if (1 < cnt[i] && cnt[i] < N - 2) {
      T[i] = cnt[i];
    }
  }
  for (int i = 0; i < N; i++) {
    if (T[i] != -1) continue;
    for (int j = 0; j < N; j++) {
      if (i != j && cnt[i] == cnt[j]) {
        if (cnt[i] == 1) {
          if (win[i][j]) {
            T[i] = 0, T[j] = 1;
          } else {
            T[j] = 0, T[i] = 1;
          }
        } else {
          if (win[i][j]) {
            T[i] = N - 2;
            T[j] = N - 1;
          } else {
            T[i] = N - 1;
            T[j] = N - 2;
          }
        }
        break;
      }
    }
  }
  return T;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...