1e5 n2 600ms
查看原帖
1e5 n2 600ms
224978
optimize_2楼主2022/11/21 19:06

如题 有人解释一下为什么这玩意这么快吗

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

inline int read() {
    char c; bool f = true;
    while (!isdigit(c = getchar())) f = c != '-';
    int x = c ^ 48;
    while (isdigit(c = getchar())) x = x * 10 + (c ^ 48);
    return f ? x : -x;
}

const int N = 500005;
const int p = 1000000007;

int n, a[N];

int main() {
    n = read();
    for (int i = 1; i <= n; i++) {
        a[i] = read();
    }
    __insertion_sort(a + 1, a + n + 1, __gnu_cxx::__ops::__iter_less_iter());
    for (int i = 1; i <= n; i++) {
        printf("%d ", a[i]);
    }
    puts("");
}
2022/11/21 19:06
加载中...