Submission #150756

# Submission time Handle Problem Language Result Execution time Memory
150756 2019-09-01T08:53:54 Z Ian and 2-bit memory(#3648, percywtc, nhho, ulna) On the Grid (FXCUP4_grid) C++17
43 / 100
65 ms 404 KB
#include "grid.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> L, ub;

const int TRIALS = 1;

bool check(int N, int target_stick, int target_level, vector<int> undetermined, vector<int>& determined) {
	for (int t = 0; t < TRIALS; t++) {
		vector<int> p(1, target_stick);
		random_shuffle(undetermined.begin(), undetermined.end());

		for (int elm : undetermined) {
			if (elm != target_stick) {
				p.push_back(elm);
			}
		}
		for (int elm : determined) {
			p.push_back(elm);
		}

		int verdict = PutDisks(p);

		int cnt = N - (verdict - N + 1) + 1;

		for (int i = 0; i < cnt; i++) {
			int guess = i + N - cnt + 1;
			ub[p[i]] = min(ub[p[i]], guess);
		}
		
		if (verdict < target_level + N - 1) {
			return false;
		}
	}

	return true;
}

bool cmp(int u, int v) {
	return L[u] < L[v];
}

vector<int> SortDisks(int N) {
	L = vector<int>(N, 0);
	ub = vector<int>(N, N);

	srand(882);

	for (int i = N; i >= 1; i--) {
		vector<int> determined, undetermined;
		for (int i = 0; i < N; i++) {
			if (L[i]) {
				determined.push_back(i);
			} else {
				undetermined.push_back(i);
			}
		}

		sort(determined.begin(), determined.end(), cmp);

		random_shuffle(undetermined.begin(), undetermined.end());
		for (int elm : undetermined) {
			if (ub[elm] < i) {
				continue;
			}
			if (check(N, elm, i, undetermined, determined)) {
				L[elm] = i;
				break;
			}
		}
	}

	return L;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 304 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 304 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 8 ms 384 KB Output is correct
10 Correct 13 ms 384 KB Output is correct
11 Correct 14 ms 384 KB Output is correct
12 Correct 14 ms 384 KB Output is correct
13 Correct 15 ms 384 KB Output is correct
14 Correct 13 ms 384 KB Output is correct
15 Correct 13 ms 384 KB Output is correct
16 Correct 14 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 304 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 8 ms 384 KB Output is correct
10 Correct 13 ms 384 KB Output is correct
11 Correct 14 ms 384 KB Output is correct
12 Correct 14 ms 384 KB Output is correct
13 Correct 15 ms 384 KB Output is correct
14 Correct 13 ms 384 KB Output is correct
15 Correct 13 ms 384 KB Output is correct
16 Correct 14 ms 384 KB Output is correct
17 Correct 24 ms 384 KB Output is correct
18 Incorrect 65 ms 404 KB Output isn't correct
19 Halted 0 ms 0 KB -