| 比赛 |
2026.3.28 |
评测结果 |
TTTTWWWWWWWWWWWWWWWW |
| 题目名称 |
逆序排列 |
最终得分 |
0 |
| 用户昵称 |
LikableP |
运行时间 |
4.822 s |
| 代码语言 |
C++ |
内存使用 |
27.33 MiB |
| 提交时间 |
2026-03-28 10:23:36 |
显示代码纯文本
#include "inv.h"
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <numeric>
int umap[2010][2010];
int myquery(int l, int r) {
if (~umap[l][r]) return umap[l][r];
return umap[l][r] = query(l, r);
}
int c, t;
void init(int c, int t) {
::c = c, ::t = t;
}
int _mp[2010][2010];
std::vector<int> solve(int n) {
memset(umap, -1, sizeof(umap));
std::vector<int> res(n);
std::iota(res.begin(), res.end(), 1);
if (1 <= c && c <= 4) {
do {
for (int i = n; i >= 1; --i) {
int cur_cnt = 0;
for (int j = i + 1; j <= n; ++j) {
if (res[i - 1] > res[j - 1]) cur_cnt ^= 1;
_mp[i][j] = _mp[i + 1][j] ^ cur_cnt;
}
}
bool ok = true;
for (int i = 1; i <= n; ++i) {
ok = true;
for (int j = i + 1; j <= n; ++j) {
if (_mp[i][j] != myquery(i, j)) {
ok = false;
break;
}
}
if (!ok) break;
}
if (ok) return res;
} while (std::next_permutation(res.begin(), res.end()));
}
return res;
}