Submission #523418

# Submission time Handle Problem Language Result Execution time Memory
523418 2022-02-07T15:44:32 Z maks007 Permutation Recovery (info1cup17_permutation) C++14
10 / 100
4000 ms 292 KB
#include <bits/stdc++.h>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector <int> Q(n);
	function <int(vector <int>)> check=[&](vector <int> a) {
		vector <int> ex = {3, 2, 4, 1};
		vector <int> res;
		for(int i = 0; i < n; i ++) {
			int cnt = 0;
			for(int mask = 0; mask < (1 << (i+1)); mask ++) {
				vector <int> ans;
				for(int j = 0; j < n; j ++) {
					if((mask & (1 << j))!=0) {
						ans.push_back(a[j]);
					}
				}
				if(is_sorted(ans.begin(), ans.end())) {
					cnt ++;
				}
			}
			cnt --;
			if(cnt != Q[i]){
				return 0;
			}
		}
		return 1;
	};
	for(int i =0; i < n; i ++) cin >> Q[i];
	vector <int> permutation(n);
	iota(permutation.begin(), permutation.end(), 1);
	do{
		if(check(permutation)) {
			for(auto i : permutation) cout << i << " ";
			return false;
		}
	}while(next_permutation(permutation.begin(), permutation.end()));
	return false;
}
# Verdict Execution time Memory Grader output
1 Correct 146 ms 272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 146 ms 272 KB Output is correct
2 Execution timed out 4054 ms 292 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 146 ms 272 KB Output is correct
2 Execution timed out 4054 ms 292 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 146 ms 272 KB Output is correct
2 Execution timed out 4054 ms 292 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 146 ms 272 KB Output is correct
2 Execution timed out 4054 ms 292 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 146 ms 272 KB Output is correct
2 Execution timed out 4054 ms 292 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 146 ms 272 KB Output is correct
2 Execution timed out 4054 ms 292 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 146 ms 272 KB Output is correct
2 Execution timed out 4054 ms 292 KB Time limit exceeded
3 Halted 0 ms 0 KB -