Submission #915738

# Submission time Handle Problem Language Result Execution time Memory
915738 2024-01-24T16:01:50 Z IBory Super Dango Maker (JOI22_dango3) C++17
100 / 100
640 ms 856 KB
#include "dango3.h"
#include <bits/stdc++.h>
#include <random>
using namespace std;

const int MAX = 10004;
int V[MAX];

void Solve(int N, int M) {
	random_device rd;
	vector<int> P;
	for (int i = 1; i <= N * M; ++i) P.push_back(i);

	for (int t = 1; t <= M; ++t) {
		vector<int> G, T;
		shuffle(P.begin(), P.end(), rd);

		for (int i = 0; i < N * M; ++i) {
			if (V[P[i]]) continue;
			G.push_back(P[i]);
		}

		if (G.size() == N) {
			Answer(G);
			return;
		}

		T.push_back(G.back()); G.pop_back();
		int idx = 0;
		while (T.size() < N) {
			swap(G[idx], G[G.size() - 1]);
			int n = G.back(); G.pop_back();
			if (Query(G) == M - t) T.push_back(n);
			else {
				G.push_back(n);
				swap(G[idx], G[G.size() - 1]);
				idx++;
			}

		}

		Answer(T);
		for (int n : T) V[n] = 1;
	}
}

Compilation message

dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:23:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |   if (G.size() == N) {
      |       ~~~~~~~~~^~~~
dango3.cpp:30:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |   while (T.size() < N) {
      |          ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 348 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 6 ms 348 KB Output is correct
5 Correct 6 ms 348 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 110 ms 600 KB Output is correct
2 Correct 111 ms 844 KB Output is correct
3 Correct 112 ms 600 KB Output is correct
4 Correct 111 ms 856 KB Output is correct
5 Correct 183 ms 600 KB Output is correct
6 Correct 111 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 431 ms 600 KB Output is correct
2 Correct 415 ms 740 KB Output is correct
3 Correct 640 ms 604 KB Output is correct
4 Correct 434 ms 600 KB Output is correct
5 Correct 516 ms 732 KB Output is correct
6 Correct 444 ms 740 KB Output is correct