답안 #163178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163178 2019-11-11T16:32:11 Z cerberus On the Grid (FXCUP4_grid) C++17
100 / 100
17 ms 396 KB
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include "grid.h"

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e3 + 10;

vector<int> SortDisks(int n) {
	vector<int> perm(n), ans(n);
	vector<bool> used(n, false);
	iota(perm.begin(), perm.end(), 0);
	int p_val = PutDisks(perm);
	int cnt = n;
	while (p_val > n) {
		rotate(perm.begin(), perm.begin() + cnt - 1, perm.begin() + cnt);
		int val = PutDisks(perm);
		if (val >= p_val) {
			ans[perm[0]] = val - n + 1;
			rotate(perm.begin(), perm.begin() + 1, perm.begin() + cnt);
			--cnt;
			sort(perm.begin() + cnt, perm.begin() + n, [&] (int x, int y) {
				return ans[x] < ans[y];
			});
		} else {
			p_val = val;
		}
	}
	for (int i = 0; i < n; ++i) {
		ans[perm[i]] = i + 1;
	}
	// for (int i = 0; i < n; ++i) {
	// 	cout << ans[i] << ' ';
	// }
	// cout << endl;
	return ans;
	// int X = PutDisks(std::vector<int>{0,2,3,1});
	// return std::vector<int>{1,X,2,3};
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 396 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 248 KB Output is correct
7 Correct 2 ms 248 KB Output is correct
8 Correct 2 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 396 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 248 KB Output is correct
7 Correct 2 ms 248 KB Output is correct
8 Correct 2 ms 248 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 5 ms 248 KB Output is correct
12 Correct 3 ms 296 KB Output is correct
13 Correct 2 ms 248 KB Output is correct
14 Correct 3 ms 248 KB Output is correct
15 Correct 3 ms 248 KB Output is correct
16 Correct 4 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 396 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 248 KB Output is correct
7 Correct 2 ms 248 KB Output is correct
8 Correct 2 ms 248 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 5 ms 248 KB Output is correct
12 Correct 3 ms 296 KB Output is correct
13 Correct 2 ms 248 KB Output is correct
14 Correct 3 ms 248 KB Output is correct
15 Correct 3 ms 248 KB Output is correct
16 Correct 4 ms 248 KB Output is correct
17 Correct 4 ms 248 KB Output is correct
18 Correct 11 ms 248 KB Output is correct
19 Correct 14 ms 248 KB Output is correct
20 Correct 17 ms 248 KB Output is correct
21 Correct 4 ms 376 KB Output is correct
22 Correct 17 ms 376 KB Output is correct
23 Correct 17 ms 380 KB Output is correct
24 Correct 17 ms 376 KB Output is correct
25 Correct 17 ms 248 KB Output is correct
26 Correct 17 ms 248 KB Output is correct