# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
287337 | eohomegrownapps | Secret Permutation (RMI19_permutation) | C++14 | 21 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "permutation.h"
#include <bits/stdc++.h>
using namespace std;
//int query(std::vector<int> v);
//void answer(std::vector<int> v);
vector<int> getDifferences(vector<int> perm){
deque<int> dq(perm.begin(),perm.end());
int n = perm.size();
vector<int> vals(n);
int tot = 0;
for (int i = 0; i<n; i++){
vector<int> q(dq.begin(),dq.end());
/*for (int x : q){
cout<<x<<' ';
}cout<<endl;*/
vals[i]=query(q);
tot+=vals[i];
dq.push_back(dq.front());
dq.pop_front();
}
vector<int> ans(n);
ans[n-1]=tot/(n-1) - vals[0];
//cout<<ans[n-1]<<'\n';
int prev = ans[n-1];
vals.push_back(vals[0]);
for (int i = 0; i<n; i++){
ans[i] = prev - (vals[i+1]-vals[i]);
prev = ans[i];
}
return ans;
}
void solve(int n){
vector<int> q1(n);
for (int i = 0; i<n; i++){
q1[i]=i+1;
}
vector<int> v1 = getDifferences(q1);
/*for (int i : v){
cout<<i<<' ';
}cout<<endl;*/
vector<int> q2;
for (int i = 1; i<=n; i+=2){
q2.push_back(i);
}
for (int i = 2; i<=n; i+=2){
q2.push_back(i);
}
vector<int> v2 = getDifferences(q2);
for (int i = 0; i<n-1; i++){
int tot;
if (i%2==0){
//cout<<"query "<<i/2<<'\n';
tot = v2[i/2];
} else {
//cout<<"query "<<(n+1)/2+i/2<<'\n';
tot = v2[(n+1)/2+i/2];
}
//cout<<tot<<'\n';
//cout<<v1[i]<<' '<<v1[i+1]<<'\n';
if (abs(v1[i]+v1[i+1])!=tot){
v1[i+1]=-v1[i+1];
}
}
/*for (int i : v1){
cout<<i<<' ';
}cout<<endl;*/
int cur = 0;
int mn = 0;
for (int i = 0; i<n-1; i++){
cur+=v1[i];
mn=min(cur,mn);
}
vector<int> ans(n);
ans[0]=1-mn;
for (int i = 1; i<n; i++){
ans[i]=ans[i-1]+v1[i-1];
}
/*for (int i : ans){
cout<<i<<' ';
}cout<<'\n';*/
answer(ans);
}
컴파일 시 표준 에러 (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... |