제출 #1353479

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

#define all(c) (c).begin(), (c).end()

/*
  if |S[a]-S[b]| = 1: returns S[a] < S[b]
  else returns S[a] > S[b]

  Choose a > b by default:
  returns a winning if 
  (S[a] > S[b] or S[b] == S[a]+1) and S[b] != S[a]-1
*/

vector<int> Solve(int N) {
  vector<vector<int>> res(N, vector<int>(N, 0));
  vector<int> T(N, -1);
  for (int a=0;a<N;a++){
    for (int b=0;b<a;b++){
      res[a][b] = Query(a, b);
      res[b][a] = 1 - res[a][b];
    }
  }
  pair<int, int> top = {-1, -1};
  pair<int, int> bot = {-1, -1};
  for (int a=0;a<N;a++){
    int cnt = accumulate(all(res[a]), 0);
    if (cnt == N-2){
      if (top.first == -1) top.first = a;
      else if (top.second == -1) top.second = a;
      else assert(false && "le caca");
    } else if (cnt == 1){
      if (bot.first == -1) bot.first = a;
      else if (bot.second == -1) bot.second = a;
      else assert(false && "le caca");
    } else T[a]=cnt;
  }

  if (res[top.first][top.second]) T[top.first] = N-1, T[top.second] = N-2;
  else T[top.first] = N-1, T[top.second] = N-2;

  if (res[bot.first][bot.second]) T[bot.first] = 0, T[bot.second] = 1;
  else T[bot.first] = 1, T[bot.second] = 0;
  
  return T;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…