답안 #864314

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
864314 2023-10-22T11:34:01 Z vjudge1 Monster Game (JOI21_monster) C++17
0 / 100
113 ms 2340 KB
#include <bits/stdc++.h>
#include "monster.h"

using namespace std;

namespace {

bool example_variable;

}  // namespace

vector<int> Solve(int N) {
    vector<int> T(N);
    bool win[N + 10][N + 10];
    int cnt[N + 10];
	vector<int> g[N + 10];
	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];
			if (win[i][j]) {
				cnt[i]++;
				g[i].push_back(j);
			}
			else {
				cnt[j]++;
				g[j].push_back(i);
			}
		}
	}
	int zero;
	for (int i = 0; i < N; i++) {
		if (cnt[i] == 1) {
			zero = i;
			T[i] = 0;
			break;
		}
	}
	bool visited[N + 10];
	memset(visited, 0, sizeof(visited));
	visited[zero] = 1;
	queue<int> q;
	q.push(zero);
	int num = 1;
	while (q.size()) {
		int f = q.front();
		q.pop();
		for (auto x : g[f]) {
			if (visited[x]) continue;
			T[x] = num++;
			visited[x] = 1;
			q.push(x);
		}
	}
	// for (auto x : T) cout << x << " ";
	// cout << endl;
    return T;
}

Compilation message

monster.cpp:8:6: warning: '{anonymous}::example_variable' defined but not used [-Wunused-variable]
    8 | bool example_variable;
      |      ^~~~~~~~~~~~~~~~
monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:31:6: warning: 'zero' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |  int zero;
      |      ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 113 ms 2340 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -