답안 #528779

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528779 2022-02-21T12:21:44 Z c28dnv9q3 Monster Game (JOI21_monster) C++17
0 / 100
219 ms 280 KB
#include "monster.h"

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

struct Monster {
	int index, wins;

	bool operator<(const Monster &m) const {
		return wins < m.wins;
	}
};

std::vector<int> T;
std::vector<Monster> monsters;

/*int findPivot(int from, int to) {
	int pivot = T[to - 1];
	for (int i = from; i < to - 1; ++i) {
		if (Query(i, pivot)) {	// i wins
			//swap(T[i], T[]);
		}
	}
}

void findSequence(int from, int to) {
	if (from == to + 1) {
		return;
	}

	int pivot = findPivot(from, to);

	findSequence(from, pivot);
	findSequence(pivot + 1, to);
}*/

std::vector<int> Solve(int N) {
	T = std::vector<int>(N);
	monsters = std::vector<Monster>(N);

	// findSequence(0, N);

	for (int i = 0; i < N; ++i) {
		monsters[i] = {i, 0};
	}

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < i; ++j) {
			if (i == j) {
				continue;
			}

			if (Query(i, j)) {	// i wins
				++monsters[i].wins;
			} else {
				++monsters[j].wins;
			}
		}
	}

	sort(monsters.begin(), monsters.end());

	if (Query(monsters[0].index, monsters[2].index)) {
		swap(monsters[0], monsters[1]);
	}
	if (!Query(monsters[N - 1].index, monsters[N - 3].index)) {
		swap(monsters[N - 1], monsters[N - 2]);
	}

	for (int i = 0; i < N; ++i) {
		T[monsters[i].index] = i;
	}

	return T;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 200 KB Output is correct
12 Correct 0 ms 200 KB Output is correct
13 Correct 1 ms 200 KB Output is correct
14 Correct 1 ms 200 KB Output is correct
15 Correct 1 ms 200 KB Output is correct
16 Correct 132 ms 200 KB Output is correct
17 Correct 145 ms 200 KB Output is correct
18 Correct 142 ms 200 KB Output is correct
19 Correct 153 ms 200 KB Output is correct
20 Correct 187 ms 200 KB Output is correct
21 Correct 1 ms 200 KB Output is correct
22 Correct 0 ms 200 KB Output is correct
23 Correct 0 ms 200 KB Output is correct
24 Correct 1 ms 200 KB Output is correct
25 Correct 1 ms 200 KB Output is correct
26 Correct 178 ms 200 KB Output is correct
27 Incorrect 0 ms 200 KB Wrong Answer [3]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 200 KB Output is correct
12 Correct 0 ms 200 KB Output is correct
13 Correct 1 ms 200 KB Output is correct
14 Correct 1 ms 200 KB Output is correct
15 Correct 1 ms 200 KB Output is correct
16 Correct 132 ms 200 KB Output is correct
17 Correct 145 ms 200 KB Output is correct
18 Correct 142 ms 200 KB Output is correct
19 Correct 153 ms 200 KB Output is correct
20 Correct 187 ms 200 KB Output is correct
21 Correct 1 ms 200 KB Output is correct
22 Correct 0 ms 200 KB Output is correct
23 Correct 0 ms 200 KB Output is correct
24 Correct 1 ms 200 KB Output is correct
25 Correct 1 ms 200 KB Output is correct
26 Correct 178 ms 200 KB Output is correct
27 Incorrect 0 ms 200 KB Wrong Answer [3]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 219 ms 280 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -