QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#774183#9792. Ogre Sortucup-team2112#WA 0ms3812kbC++231.6kb2024-11-23 12:16:502024-11-23 12:16:51

Judging History

This is the latest submission verdict.

  • [2024-11-23 12:16:51]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3812kb
  • [2024-11-23 12:16:50]
  • Submitted

answer

#include <bits/stdc++.h>

struct Fenwick_Tree{
    std::vector<int> c;
    int n;
    Fenwick_Tree(int n) : n(n) {
        c.resize(n + 1);
    }
    void add(int x, int y) {
        for (int i = x; i <= n; i += i & -i) {
            c[i] += y;
        }
    }
    int query(int x) {
        int res = 0;
        for (int i = x; i > 0; i -= i & -i) {
            res += c[i];
        }
        return res;
    }

    int kth(int k) {
        int res = 0;
        for (int i = 1 << std::__lg(n); i > 0; i >>= 1) {
            if (res + i <= n && c[res + i] < k) {
                k -= c[res + i];
                res += i;
            }
        }
        return res + 1;
    }
};

using i64 = long long;

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    int n;
    std::cin >> n;
    std::vector<int> a(n + 1);
    std::vector<int> ord(n + 1);

    for (int i = 1; i <= n; i += 1){
        std::cin >> a[i];
    }
    Fenwick_Tree tree(n);
    for (int i = n; i >= 1; i -= 1) {
        if (i == a[i]) continue;
        std::cout << i - 1 << " " << i - 1 << "\n";
        std::vector<int> ord(i + 1);
        for (int j = 1; j <= i; j += 1) {
            ord[j] = j;
        }
        std::sort(ord.begin() + 1, ord.end(), [&](int x, int y) {
            return a[x] > a[y];
        });
        for (int j = 2; j <= i; j += 1) {
            std::cout << ord[j] + tree.query(n - ord[j] + 1) << " " << 1 << "\n";
            tree.add(n - ord[j] + 1, 1);
        }
        return 0;
    }
    std::cout << "0 0\n";
    return 0; 
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3544kb

input:

4
1 2 4 3

output:

3 3
4 1
3 1
3 1

result:

ok Participant's output is correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

5
2 4 1 3 5

output:

3 3
4 1
2 1
4 1

result:

ok Participant's output is correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

3
1 2 3

output:

0 0

result:

ok Participant's output is correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

4
1 2 4 3

output:

3 3
4 1
3 1
3 1

result:

ok Participant's output is correct

Test #5:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

5
2 4 1 3 5

output:

3 3
4 1
2 1
4 1

result:

ok Participant's output is correct

Test #6:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

3
1 2 3

output:

0 0

result:

ok Participant's output is correct

Test #7:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

1
1

output:

0 0

result:

ok Participant's output is correct

Test #8:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

5
5 3 4 1 2

output:

4 4
3 1
3 1
5 1
5 1

result:

ok Participant's output is correct

Test #9:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

5
4 1 2 3 5

output:

3 3
4 1
4 1
4 1

result:

ok Participant's output is correct

Test #10:

score: -100
Wrong Answer
time: 0ms
memory: 3544kb

input:

5
1 3 4 2 5

output:

3 3
2 1
4 1
3 1

result:

wrong answer Integer parameter [name=participant answer] equals to 3, violates the range [0, 2]