# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
259615 | tqbfjotld | Secret Permutation (RMI19_permutation) | C++14 | 3807 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "permutation.h"
#include <bits/stdc++.h>
using namespace std;
int arr[300];
int n;
vector<int> inv(){
vector<int> ans;
for (int x = 0; x<n; x++){
ans.push_back(0);
}
for (int x = 1; x<=n; x++){
ans[arr[x]-1] = x;
}
return ans;
}
void solve(int N) {
n = N;
for (int x = 1; x<=n; x++){
arr[x] = x;
}
while (true){
if (query(inv())==n-1){
vector<int> ans;
for (int x = 1; x<=n; x++){
ans.push_back(arr[x]);
}
answer(ans);
break;
}
pair<int,int> best = {-1,-1};
int bestv = 999999999;
vector<pair<int,pair<int,int> > >rem;
for (int x = 1; x<=n; x++){
for (int y = x+1; y<=n; y++){
rem.push_back({rand(),{x,y}});
}
}
sort(rem.begin(),rem.end());
int threshold = n*n;
for (int x = 0; x<min(threshold,(int)rem.size()); x++){
swap(arr[rem[x].second.first],arr[rem[x].second.second]);
int t = query(inv());
if (t<bestv){
best = rem[x].second;
bestv = t;
}
swap(arr[rem[x].second.first],arr[rem[x].second.second]);
}
swap(arr[best.first],arr[best.second]);
}
}
컴파일 시 표준 에러 (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... |