Submission #1084209

# Submission time Handle Problem Language Result Execution time Memory
1084209 2024-09-05T15:49:00 Z yoav_s Monster Game (JOI21_monster) C++17
10 / 100
160 ms 600 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<vv> vvv;
typedef pair<ll, ll> p;
typedef vector<p> vp;
typedef vector<vp> vvp;
typedef vector<vvp> vvvp;
typedef pair<ll, p> tri;
typedef vector<tri> vtri;
typedef vector<vtri> vvtri;
typedef vector<vvtri> vvvtri;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vvb> vvvb;

#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()

const ll INF = 1e18;
const ll mod = 1e9 + 7;

#include "monster.h"

bool wins(ll a, ll b)
{
    if (abs(a - b) == 1)
    {
        return a < b;
    }
    return a > b;
}

vector<int> Solve(int N)
{
    vvb winning(N, vb(N, false));
    for (ll i = 0; i < N; i++)
    {
        for (ll j = 0; j < i; j++)
        {
            winning[i][j] = Query(i, j);
            winning[j][i] = !winning[i][j];
        }
    }
    v winningAmt(N);
    for (ll i =0 ; i < N; i++)
    {
        for (ll j = 0; j < N; j++) winningAmt[i] += winning[i][j];
    }
    vv byAmt(N);
    for (ll i = 0; i < N; i++) byAmt[winningAmt[i]].pb(i);
    vector<int> res(N);
    for (ll i = 2; i < N - 2; i++)
    {
        res[byAmt[i][0]] = i;
    }
    if (winning[byAmt[1][0]][byAmt[1][1]])
    {
        res[byAmt[1][0]] = 0;
        res[byAmt[1][1]] = 1;
    }
    else
    {
        res[byAmt[1][0]] = 1;
        res[byAmt[1][1]] = 0;
    }
    if (winning[byAmt[N - 2][0]][byAmt[N - 2][1]])
    {
        res[byAmt[N - 2][0]] = N - 2;
        res[byAmt[N - 2][1]] = N - 1;
    }
    else
    {
        res[byAmt[N - 2][0]] = N - 1;
        res[byAmt[N - 2][1]] = N - 2;
    }
    return res;
}
/*
namespace {

using std::exit;
using std::fprintf;
using std::printf;
using std::scanf;

constexpr int Q_MAX = 25'000;
constexpr int N_MAX = 1'000;

int N;
int S[N_MAX];

int query_count = 0;

void WrongAnswer(int code) {
  printf("Wrong Answer [%d]\n", code);
  exit(0);
}

}  // namespace

bool Query(int a, int b) {
  if (++query_count > Q_MAX) WrongAnswer(6);
  if (a < 0 || N <= a || b < 0 || N <= b) WrongAnswer(4);
  if (a == b) WrongAnswer(5);
  return (S[a] > S[b]) ^ (abs(S[a] - S[b]) == 1);
}

int main() {
  if (scanf("%d", &N) != 1) {
    fprintf(stderr, "Error while reading.\n");
    exit(1);
  }
  for (int i = 0; i < N; i++) {
    if (scanf("%d", S + i) != 1) {
      fprintf(stderr, "Error while reading.\n");
      exit(1);
    }
  }
  std::vector<int> T = Solve(N);
  if ((int)T.size() != N) WrongAnswer(1);
  for (int i = 0; i < N; i++) {
    if (T[i] < 0 || N <= T[i]) WrongAnswer(2);
    if (T[i] != S[i]) WrongAnswer(3);
  }
  printf("Accepted: %d\n", query_count);
  return 0;
}
/**/

Compilation message

monster.cpp:136:1: warning: "/*" within comment [-Wcomment]
  136 | /**/
      |
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 108 ms 432 KB Output is correct
17 Correct 141 ms 424 KB Output is correct
18 Correct 121 ms 428 KB Output is correct
19 Correct 102 ms 444 KB Output is correct
20 Correct 94 ms 424 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 88 ms 432 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 94 ms 428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 108 ms 432 KB Output is correct
17 Correct 141 ms 424 KB Output is correct
18 Correct 121 ms 428 KB Output is correct
19 Correct 102 ms 444 KB Output is correct
20 Correct 94 ms 424 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 88 ms 432 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 94 ms 428 KB Output is correct
33 Incorrect 122 ms 600 KB Wrong Answer [6]
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 160 ms 596 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -