답안 #1061171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061171 2024-08-16T06:57:35 Z sleepntsheep Monster Game (JOI21_monster) C++17
10 / 100
129 ms 600 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;
              taken[i] = 1;
              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;
      |                       ^
# 결과 실행 시간 메모리 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 0 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 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 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 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 91 ms 556 KB Output is correct
17 Correct 129 ms 560 KB Output is correct
18 Correct 114 ms 600 KB Output is correct
19 Correct 106 ms 572 KB Output is correct
20 Correct 118 ms 560 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 85 ms 560 KB Output is correct
27 Correct 0 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 0 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 89 ms 560 KB Output is correct
# 결과 실행 시간 메모리 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 0 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 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 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 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 91 ms 556 KB Output is correct
17 Correct 129 ms 560 KB Output is correct
18 Correct 114 ms 600 KB Output is correct
19 Correct 106 ms 572 KB Output is correct
20 Correct 118 ms 560 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 85 ms 560 KB Output is correct
27 Correct 0 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 0 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 89 ms 560 KB Output is correct
33 Runtime error 1 ms 600 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -