QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#367422 | #91. Secret Permutation | Max_s_xaM | 0 | 1ms | 3908kb | C++20 | 1.7kb | 2024-03-25 22:34:12 | 2024-03-25 22:34:14 |
answer
#include <iostream>
#include <random>
#include <algorithm>
#include <vector>
#include <cmath>
typedef long long ll;
typedef double lf;
// #define DEBUG 1
using namespace std;
const int MAXN = 260, B = 258;
#include "permutation.h"
mt19937 Rand(102934);
int n, idx[MAXN], a[MAXN], d[MAXN];
vector <int> qry;
int ans[MAXN], rt;
bool vis[MAXN << 1];
inline bool Solve(int cur, int p, int l, int r)
{
if (r - l > n - 1 || vis[p + B]) return 0;
if (cur == n)
{
ans[cur] = p;
if (p + d[n] == 0 || p - d[n] == 0) return rt = l, 1;
return 0;
}
vis[p + B] = 1, ans[cur] = p;
if (Solve(cur + 1, p + d[cur], l, max(r, p + d[cur]))) return 1;
if (Solve(cur + 1, p - d[cur], min(l, p - d[cur]), r)) return 1;
vis[p + B] = 0;
return 0;
}
void solve(int N)
{
n = N;
for (int i = 1; i <= n; i++) idx[i] = i;
swap(idx[Rand() % n + 1], idx[Rand() % n + 1]);
qry.clear();
for (int i = 1; i <= n; i++) qry.push_back(idx[i]);
a[0] = query(qry);
qry.clear();
for (int i = 1; i <= n; i++) qry.push_back(i);
answer(qry);
return;
int sum = 0;
for (int i = 1; i <= n - 1; i++)
{
qry.clear();
for (int j = i; j >= 1; j--) qry.push_back(idx[j]);
for (int j = n; j > i; j--) qry.push_back(idx[j]);
a[i] = query(qry), sum += a[i];
}
sum -= (n - 2) * a[0], sum /= n - 1;
d[n] = sum;
for (int i = 1; i <= n - 1; i++) d[i] = a[0] - a[i] + d[n];
// Solve(1, 0, 0, 0);
// qry.resize(n);
// qry[idx[1] - 1] = 1 - rt;
// for (int i = 2; i <= n; i++) qry[idx[i] - 1] = qry[idx[1] - 1] + ans[i];
// answer(qry);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3908kb
input:
7 5 7 1 3 2 4 6
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%