Submission #1061166

# Submission time Handle Problem Language Result Execution time Memory
1061166 2024-08-16T06:56:54 Z sleepntsheep Monster Game (JOI21_monster) C++17
0 / 100
1 ms 740 KB
#include "monster.h"
using namespace std;

namespace {
}

vector<int> Solve(int N) {
  static int a[201][201], w[201], l[201];
  for (int i = 0; i < N; ++i) w[i] = 0, l[i] = 0;
  for (int i = 0; i < N; ++i) for (int j = i + 1; j < N; ++j) {
      a[i][j] = Query(i, j);
      if (a[i][j]) ++w[i];
      else ++w[j];
      a[j][i] = !a[i][j];
  }

  int x1 { -1 }, x2;
  for (int i = 0; i < N; ++i) {
      if (w[i] == 1) {
          if (~x1) x2 = i;
          else x1 = i;
      }
  }

  vector<int> T(N), taken(N), Q(N);
  if (a[x1][x2]) T[0] = x1, T[1] = x2;
  else T[0] = x2, T[1] = x1;

  taken[x1] = taken[x2] = 1;

  for (int j = 2; j < N; ++j) {
      for (int i = 0; i < N; ++i) if (not taken[i]) {
          if (a[T[j - 1]][i]) {
              T[j] = i;
              break;
          }
      }
  }

  for (int i = 0; i < N; ++i) Q[T[i]] = i;
  return Q;
}

Compilation message

monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:8:35: warning: variable 'l' set but not used [-Wunused-but-set-variable]
    8 |   static int a[201][201], w[201], l[201];
      |                                   ^
monster.cpp:29:23: warning: 'x2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |   taken[x1] = taken[x2] = 1;
      |                       ^
# 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 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 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 0 ms 344 KB Output is correct
10 Incorrect 0 ms 344 KB Wrong Answer [3]
11 Halted 0 ms 0 KB -
# 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 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 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 0 ms 344 KB Output is correct
10 Incorrect 0 ms 344 KB Wrong Answer [3]
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 740 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -