QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#692724 | #91. Secret Permutation | HJY2022 | 0 | 0ms | 3996kb | C++20 | 1.0kb | 2024-10-31 14:57:31 | 2024-10-31 14:57:31 |
answer
#include<bits/stdc++.h>
#include "permutation.h"
using namespace std;
const int MX = 305;
int a[MX],d[MX],ans[MX];bool vis[MX];
bool dfs(int x,int p,int N,int mn,int mx){
if(mx - mn > N - 1 || vis[p + MX])return 0;
ans[x] = p;
if(x == N){
if(p - d[N] == 0 || p + d[N] == 0)return 1;
return 0;
}
vis[p + MX] = true;
if(dfs(x + 1,p + d[x],N,mn,max(mx,p + d[x])))return 1;
if(dfs(x + 1,p - d[x],N,min(mn,p - d[x]),mx))return 1;
vis[p + MX] = false;
return false;
}
void solve(int N){
vector<int > q;q.resize(N);
for(int i = 0;i < N;i++)q[i] = i + 1;
a[0] = query(q);int sum = 0;
for(int i = 1;i < N;i++){
int p = 0;
for(int j = i;j >= 1;j--)q[p++] = j;
for(int j = N;j > i;j--)q[p++] = j;
a[i] = query(q);sum += a[i];
}
sum -= (N - 2) * a[0];sum /= (N - 1);
for(int i = 1;i < N;i++)d[i] = a[0] - a[i] + sum;d[N] = sum;
dfs(1,0,N,0,0);int mn = 1000000000;
for(int i = 1;i <= N;i++)mn = min(mn,ans[i]);
for(int i = 0;i < N;i++)q[i] = ans[i + 1] - mn + 1;
answer(q);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 15
Accepted
time: 0ms
memory: 3996kb
input:
7 5 7 1 3 2 4 6
output:
0 7 1050790
result:
points 1.0 7 steps
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 3800kb
input:
4 3 4 2 1
output:
-1
result:
wrong answer Your answer is not correct.
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%