QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#589374#5305. Oscar is All You Needlouhao088#WA 0ms3840kbC++231.2kb2024-09-25 17:33:402024-09-25 17:33:42

Judging History

你现在查看的是最新测评结果

  • [2024-09-25 17:33:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2024-09-25 17:33:40]
  • 提交

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