답안 #433205

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
433205 2021-06-19T08:06:27 Z hhhhaura Permutation Recovery (info1cup17_permutation) C++14
10 / 100
4000 ms 204 KB
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)

#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))

#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)

using namespace std;

#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())

#ifdef wiwihorz
#define print(a...) kout("[" + string(#a) + "] = ", a) 
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); }
#else
#define print(...) 0
#define vprint(...) 0
#endif
namespace solver {
	int n; 
	vector<int> q, p, dp;
	void init_(int _n) {
		n = _n;
		q.assign(n + 1, 0);
		p.assign(n + 1, 0);
		rep(i, 1, n) p[i] = i;
	}
	void solve() {
		do {
			dp.assign(n + 1, 0);
			dp[0] = 1;
			rep(i, 1, n) rep(j, 0, i - 1) {
				if(p[j] < p[i]) dp[i] += dp[j];
			}
			bool yes = 1;
			dp[0] = 0;
			rep(i, 1, n) {
				dp[i] += dp[i - 1];
				yes &= (dp[i] == q[i]);
			}
			if(yes) {
				rep(i, 1, n) cout << p[i] << " \n"[i == n];
				return ;
			}
		
		} while(next_permutation(p.begin() + 1, p.end()));
	}
};
using namespace solver;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n; cin >> n; init_(n);
	rep(i, 1, n) cin >> q[i];
	solve();
	return 0;
}

Compilation message

permutation.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
permutation.cpp:24:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
permutation.cpp:24:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 204 KB Output is correct
2 Execution timed out 4067 ms 204 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 204 KB Output is correct
2 Execution timed out 4067 ms 204 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 204 KB Output is correct
2 Execution timed out 4067 ms 204 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 204 KB Output is correct
2 Execution timed out 4067 ms 204 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 204 KB Output is correct
2 Execution timed out 4067 ms 204 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 204 KB Output is correct
2 Execution timed out 4067 ms 204 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 204 KB Output is correct
2 Execution timed out 4067 ms 204 KB Time limit exceeded