Submission #864318

# Submission time Handle Problem Language Result Execution time Memory
864318 2023-10-22T11:50:15 Z vjudge1 Monster Game (JOI21_monster) C++17
0 / 100
113 ms 2560 KB
#include <bits/stdc++.h>
#include "monster.h"

using namespace std;

namespace {

bool example_variable;

}  // namespace

vector<int> Solve(int N) {
	if (N == 1) return {0};
    vector<int> T(N);
    bool win[N + 10][N + 10];
    int cnt[N + 10];
	memset(cnt, 0, sizeof(cnt));
	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);
			if (win[i][j]) {
				cnt[i]++;
				g[i].push_back(j);
			}
			else {
				cnt[j]++;
				g[j].push_back(i);
			}
		}
	}
	int zero;
	vector<int> v;
	for (int i = 0; i < N; i++) {
		if (cnt[i] == 1) {
			v.push_back(i);
		}
	}
	zero = v[0];
	T[v[0]] = 0;
	if (v.size() > 1) {
		if (win[g[v[0]][0]][g[v[1]][0]]) {}
		else {
			zero = v[1];
			T[v[1]] = 0;
		}
	}
	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;
      |      ^~~~~~~~~~~~~~~~
# 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 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 344 KB Wrong Answer [3]
7 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 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 Incorrect 0 ms 344 KB Wrong Answer [3]
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 113 ms 2560 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -