QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#589374 | #5305. Oscar is All You Need | louhao088# | WA | 0ms | 3840kb | C++23 | 1.2kb | 2024-09-25 17:33:40 | 2024-09-25 17:33:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1050;
int n, p[N], tmp[N], id[N];
vector <pair<int, int> > s;
void work(int x, int y) {
s.push_back(make_pair(x, y));
tmp[0] = 0;
for (int i = n - y + 1; i <= n; i++) tmp[++tmp[0]] = p[i];
for (int i = x + 1; i <= n - y; i++) tmp[++tmp[0]] = p[i];
for (int i = 1; i <= x; i++) tmp[++tmp[0]] = p[i];
for (int i = 1; i <= n; i++) p[i] = tmp[i], id[p[i]] = i;
}
void write() {
printf("%d\n", s.size());
for (int i = 0; i < s.size(); i++) printf("%d %d\n", s[i].first, s[i].second);
}
void slove() {
s.clear();
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &p[i]), id[p[i]] = i;
if (p[1] != 1) {
work(id[1] - 1, n - id[1]);
work(id[1] - 2, n - id[1] + 1);
}
for (int i = 1; i <= n - 2; i++) {
if (p[i] == i) continue;
if (id[i] == n) {
work(i - 1, 1);
work(id[i] - 1, n - id[i]);
}
else {
work(i, 1);
work(id[1] - 1, 1);
}
}
write();
}
int main() {
int t; scanf("%d", &t);
while (t--) slove();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3840kb
input:
2 3 1 3 2 5 4 1 2 3 5
output:
0 4 1 3 2 2 2 1 3 1
result:
wrong answer Jury have smaller lexicographical order