QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#774173#9792. Ogre Sortucup-team2112#WA 0ms3852kbC++201.6kb2024-11-23 12:14:452024-11-23 12:14:47

Judging History

This is the latest submission verdict.

  • [2024-11-23 12:14:47]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3852kb
  • [2024-11-23 12:14:45]
  • 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 >= 0; i -= 1) {
        if (i && 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);
        }
        break;
    }
    return 0; 
}

詳細信息

Test #1:

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

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: 3656kb

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: -100
Wrong Answer
time: 0ms
memory: 3620kb

input:

3
1 2 3

output:

-1 -1

result:

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