제출 #1139585

#제출 시각아이디문제언어결과실행 시간메모리
1139585stdfloatPermutation Recovery (info1cup17_permutation)C++20
0 / 100
1094 ms324 KiB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define sz(v)	(int)(v).size()
#define all(v)	(v).begin(), (v).end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	int n;
	cin >> n;

	vector<int> a(n);
	for (auto &i : a)
		cin >> i;

	vector<int> p(n);
	iota(all(p), 1);
	do {
		bool tr = true;
		vector<int> v(n, 1);
		for (int i = 0; i < n && tr; i++) {
			for (int j = 0; j < i; j++)
				if (p[j] < p[i]) v[i] += v[j];

			tr = (a[i] - (i ? a[i - 1] : 0) == v[i]);
		}

		if (tr) {
			for (auto i : p)
				cout << i << ' ';
			return 0;
		}
	} while (next_permutation(all(p)));
}
#Verdict Execution timeMemoryGrader output
Fetching results...