QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#774178#9792. Ogre Sortucup-team2112#Compile Error//C++201.6kb2024-11-23 12:15:522024-11-23 12:15:53

Judging History

This is the latest submission verdict.

  • [2024-11-23 12:15:53]
  • Judged
  • [2024-11-23 12:15:52]
  • 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::print("0 0\n");
    return 0; 
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:65:10: error: ‘print’ is not a member of ‘std’; did you mean ‘rint’?
   65 |     std::print("0 0\n");
      |          ^~~~~
      |          rint