| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1054175 | socpite | Secret Permutation (RMI19_permutation) | C++17 | 5064 ms | 596 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "permutation.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 300;
namespace {
	long long D[maxn];
	bool vis[maxn];
	vector<int> crr;
	vector<vector<int>> allans;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
}
void bt(int pos, int n){
	if(pos > n){
		if(abs(crr.back() - crr[0]) != D[1])return;
		allans.push_back(crr);
		return;
	}
	int tmp = crr.back() + D[pos]; 
	if(tmp <= n && !vis[tmp]){
		crr.push_back(tmp);
		vis[tmp] = 1;
		bt(pos+1, n);
		vis[tmp] = 0;
		crr.pop_back();
	}
	
	tmp = crr.back() - D[pos]; 
	if(tmp > 0 && !vis[tmp]){
		crr.push_back(tmp);
		vis[tmp] = 1;
		bt(pos+1, n);
		vis[tmp] = 0;
		crr.pop_back();
	}
}
void solve(int N) {
	long long sum = 0;
	vector<int> P(N);
	iota(P.begin(), P.end(), 1);
	for(int i = 1; i <= N; i++){
		D[i] = query(P);
		sum += D[i];
		P.push_back(P[0]);
		P.erase(P.begin());
	}
	sum /= N-1;
	for(int i = 1; i <= N; i++){
		D[i] = sum - D[i];
		// cout << D[i] << endl;
	}
	allans.clear();
	for(int i = 1; i <= N; i++){
		crr.push_back(i);
		vis[i] = 1;
		bt(2, N);
		vis[i] = 0;
		crr.pop_back();
	}
	while(allans.size() > 2){
		shuffle(P.begin(), P.end(), rng);
		vector<vector<int>> nw;
		int chksum = query(P);
		for(auto vec: allans){
			int csum = 0;
			for(int i = 1; i < N; i++)csum += abs(vec[P[i]-1] - vec[P[i-1]-1]);
			if(csum == chksum)nw.push_back(vec);
		}
		allans = nw;
	}
	answer(allans.back());
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
