Submission #951915

# Submission time Handle Problem Language Result Execution time Memory
951915 2024-03-23T01:29:31 Z Gromp15 Super Dango Maker (JOI22_dango3) C++17
100 / 100
100 ms 644 KB
#include "dango3.h"
#include <random>
#include <vector>
#include <chrono>
#include <algorithm>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;

void Solve(int n, int m) {
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	vector<bool> used(n*m);
	for (int t = 0; t < m; t++) {
		vector<int> here;
		for (int i = 0; i < n*m; i++) if (!used[i]) {
			here.push_back(i + 1);
		}
		if (t == m-1) {
			Answer(here);
			return;
		}
		shuffle(all(here), rng);
		int l = n, r = sz(here) - 1, ans = sz(here);
		while (l <= r) {
			int mid = (l+r)/2;
			int got = Query(vector<int>(here.begin(), here.begin() + mid));
			if (got >= 1) ans = mid, r = mid-1;
			else l = mid+1;
		}
		here.resize(ans);
		for (int i = 0; i < (int)here.size(); i++) {
			int orig = here[i];
			here.erase(here.begin() + i);
			int res = Query(here);
			if (res == 0) here.insert(here.begin() + i, orig);
			else i--;
		}
		Answer(here);
		for (int x : here) used[x-1] = 1;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 348 KB Output is correct
2 Correct 21 ms 568 KB Output is correct
3 Correct 20 ms 344 KB Output is correct
4 Correct 24 ms 348 KB Output is correct
5 Correct 22 ms 344 KB Output is correct
6 Correct 21 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 604 KB Output is correct
2 Correct 96 ms 640 KB Output is correct
3 Correct 93 ms 640 KB Output is correct
4 Correct 97 ms 600 KB Output is correct
5 Correct 93 ms 604 KB Output is correct
6 Correct 93 ms 644 KB Output is correct