pbds的错误做法

P1908 逆序对

kubekube @ 2023-12-31 17:02:51

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef int MYTYPE_INDEX; // index
typedef null_type MYTYPE_VALUE;

map<string,bool> M;

tree<   MYTYPE_INDEX,
        MYTYPE_VALUE,
        less< MYTYPE_INDEX >,
        rb_tree_tag, // red black
        tree_order_statistics_node_update
        > TR;

const int maxn = 5e5 + 10;
int A[maxn];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    long long ans = 0;

    for (int i = 0; i < n; i++) {
        int x = A[i];
        ans += TR.order_of_key(x); // 这里我能想到3种写法哦~~
        TR.insert(x);
    }
    cout << ans;

    return 0;
}

by 09876443ii @ 2023-12-31 17:04:38

哪错了


by heyx0201 @ 2023-12-31 17:12:54

@kubekube ???????


by kubekube @ 2024-01-05 23:37:54

@heyx0201 无关紧要的小错误,从大到小与从小到大


by kexiye @ 2024-01-30 15:29:00

what are you doing now?


by kexiye @ 2024-02-17 16:53:36

2024寒假CSP-J训练营7班老师?


|