Submission #199106

# Submission time Handle Problem Language Result Execution time Memory
199106 2020-01-29T11:43:14 Z bsyo2k On the Grid (FXCUP4_grid) C++17
100 / 100
24 ms 428 KB
#include "grid.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1005;

int chk[MAXN];
vector<int> SortDisks(int N) {
	vector<int> v, ans;
	ans.resize(N);
	for(int i = 0; i < N; i++) v.push_back(i);
	for(int i = 0; i < N; i++) chk[i] = -1;

	int X = PutDisks(v);
	while(!v.empty()) {
		vector<int> w;
		int t = v.back();
		for(int i = v.size() - 1; i > 0; i--)
			v[i] = v[i - 1];

		v[0] = t;
		int p = 0;

		for(int i = 0; i < N; i++) {
			if(chk[i] != -1) w.push_back(chk[i]);
			else w.push_back(v[p++]);
		}

		int Y = PutDisks(w);
		if(Y >= X) {
			t = v[0];
			ans[t] = Y;
			for(int i = N - 1; w[i] != v[0]; i--) 
				ans[t]--;

			chk[ans[t] - 1] = t;

			for(int i = 0; i < v.size() - 1; i++) 
				v[i] = v[i + 1];

			v.pop_back();
		}
		else X = Y;
	}
	return ans;
}

Compilation message

grid.cpp: In function 'std::vector<int> SortDisks(int)':
grid.cpp:38:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i = 0; i < v.size() - 1; i++) 
                   ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 6 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 6 ms 256 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 6 ms 256 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 9 ms 380 KB Output is correct
18 Correct 16 ms 428 KB Output is correct
19 Correct 21 ms 416 KB Output is correct
20 Correct 22 ms 376 KB Output is correct
21 Correct 13 ms 376 KB Output is correct
22 Correct 23 ms 392 KB Output is correct
23 Correct 22 ms 352 KB Output is correct
24 Correct 24 ms 376 KB Output is correct
25 Correct 22 ms 376 KB Output is correct
26 Correct 22 ms 376 KB Output is correct