# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
685385 | dranaya_dusha | Secret Permutation (RMI19_permutation) | C++17 | 0 ms | 208 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
////#define int long long
//#define mp make_pair
//#define pb push_back
//#define fi first
//#define se second
//#define pii pair <int, int>
#include "permutation.h"
using namespace std;
vector<int> ans;
//bool check (vector<int> &q, int p, int n)
//{
// ans.assign(n, 0);
// vector<int> used(n+1);
// ans[p]=1;
// used[1]=1;
// for (int i=p; i<n-1; i++)
// if (ans[i]+q[i]<=n && !used[ans[i]+q[i]]){
// ans[i+1]=ans[i]+q[i];
// used[ans[i]+q[i]]=1;
// }
// else if (ans[i]-q[i]>0 && !used[ans[i]-q[i]])
// {
// ans[i+1]=ans[i]-q[i];
// used[ans[i]-q[i]]=1;
// }
// else return false;
// for (int i=p; i>0; i--)
// {
// if (ans[i] + q[i - 1] <= n && !used[ans[i] + q[i - 1]]){
// ans[i - 1] = ans[i] + q[i - 1];
// used[ans[i] + q[i - 1]] = 1;
// }
// else if (ans[i] - q[i - 1] > 0 && !used[ans[i] - q[i - 1]])
// {
// ans[i-1] = ans[i]-q[i - 1];
// used[ans[i] - q[i - 1]] = 1;
// }
// else return false;
// }
// return true;
//}
void check2(vector<int>&q, int n)
{
vector<int> a(n);
for (int i=1; i<=n; i++)
a[i-1]=i;
do
{
bool mark = 1;
for (int i=0; i<n-1; i++)
if (abs(a[i]-a[i+1])!=q[i]) mark = 0;
if (mark){
ans = a;
return;
}
}while (next_permutation(a.begin(), a.end()));
}
void solve(int n) {
vector<int> V = {1, 2};
vector<int> q(n);
for (int i=0; i<n-1; i++){
q[i] = query(V);
V[0]++;
V[1]++;
}
ans.assign(n, 0);
check2(q, 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... |