답안 #1011964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011964 2024-07-01T12:51:22 Z kaopj Cryptography (NOI20_crypto) C++17
35 / 100
862 ms 33904 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define orderedset tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define lgm cin.tie(0)->sync_with_stdio(0);
const int mod = 1e9+7;
using namespace std;
signed main() {
    lgm;
    orderedset s;
    int n;
    cin >> n;
    vector<pair<int,int>> o(n);
    vector<int> num(n);
    for (int i=0;i<n;i++) {
        cin >> num[i];
        o[i]={num[i],i};
    }
    sort(o.begin(),o.end());
    int ans=0;
    for (int i=0;i<n;i++) {
        num[o[i].second]=i;
    }
    vector<int> lesscnt(n);
    int f[n+1];
    f[0]=1;
    f[1]=1;
    for (int i=2;i<=n;i++) {
        f[i]=i*f[i-1]%mod;
    }
    for (int i=n-1;i>=0;i--) {
        int l=0,r=n-1-i,m;
        while (l<r) {
            m=(l+r)>>1;
            if (*s.find_by_order(m) >= num[i]) {
                r=m;
            } else {
                l=m+1;
            }
        }
        lesscnt[i]=l;
        s.insert(num[i]);
    }
    for (int i=0;i<n;i++) {
        ans=(ans+f[n-i-1]*lesscnt[i])%mod;
    }
    cout << ans+1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 756 ms 33904 KB Output is correct
3 Correct 770 ms 33700 KB Output is correct
4 Correct 752 ms 33872 KB Output is correct
5 Correct 776 ms 33732 KB Output is correct
6 Correct 809 ms 33856 KB Output is correct
7 Correct 827 ms 33836 KB Output is correct
8 Correct 812 ms 33816 KB Output is correct
9 Correct 802 ms 33864 KB Output is correct
10 Correct 800 ms 33876 KB Output is correct
11 Correct 836 ms 33872 KB Output is correct
12 Correct 806 ms 33708 KB Output is correct
13 Correct 747 ms 33876 KB Output is correct
14 Correct 788 ms 33864 KB Output is correct
15 Correct 806 ms 33692 KB Output is correct
16 Correct 819 ms 33876 KB Output is correct
17 Correct 801 ms 33736 KB Output is correct
18 Correct 832 ms 33648 KB Output is correct
19 Correct 762 ms 33732 KB Output is correct
20 Correct 774 ms 33876 KB Output is correct
21 Correct 736 ms 33624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 838 ms 32704 KB Output is correct
3 Correct 775 ms 32704 KB Output is correct
4 Correct 816 ms 32704 KB Output is correct
5 Correct 807 ms 32852 KB Output is correct
6 Correct 825 ms 32840 KB Output is correct
7 Correct 785 ms 32916 KB Output is correct
8 Correct 793 ms 32732 KB Output is correct
9 Correct 839 ms 32920 KB Output is correct
10 Correct 808 ms 32948 KB Output is correct
11 Correct 813 ms 32836 KB Output is correct
12 Correct 803 ms 32848 KB Output is correct
13 Correct 801 ms 32852 KB Output is correct
14 Correct 835 ms 32744 KB Output is correct
15 Correct 829 ms 32848 KB Output is correct
16 Correct 862 ms 32812 KB Output is correct
17 Correct 852 ms 32864 KB Output is correct
18 Correct 830 ms 32748 KB Output is correct
19 Correct 828 ms 32848 KB Output is correct
20 Correct 852 ms 32852 KB Output is correct
21 Correct 852 ms 32852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 600 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 460 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 3 ms 604 KB Output is correct
27 Correct 3 ms 604 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 3 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 3 ms 604 KB Output is correct
33 Correct 3 ms 604 KB Output is correct
34 Correct 3 ms 604 KB Output is correct
35 Correct 3 ms 604 KB Output is correct
36 Correct 3 ms 600 KB Output is correct
37 Correct 3 ms 604 KB Output is correct
38 Correct 3 ms 604 KB Output is correct
39 Incorrect 0 ms 348 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 838 ms 32704 KB Output is correct
3 Correct 775 ms 32704 KB Output is correct
4 Correct 816 ms 32704 KB Output is correct
5 Correct 807 ms 32852 KB Output is correct
6 Correct 825 ms 32840 KB Output is correct
7 Correct 785 ms 32916 KB Output is correct
8 Correct 793 ms 32732 KB Output is correct
9 Correct 839 ms 32920 KB Output is correct
10 Correct 808 ms 32948 KB Output is correct
11 Correct 813 ms 32836 KB Output is correct
12 Correct 803 ms 32848 KB Output is correct
13 Correct 801 ms 32852 KB Output is correct
14 Correct 835 ms 32744 KB Output is correct
15 Correct 829 ms 32848 KB Output is correct
16 Correct 862 ms 32812 KB Output is correct
17 Correct 852 ms 32864 KB Output is correct
18 Correct 830 ms 32748 KB Output is correct
19 Correct 828 ms 32848 KB Output is correct
20 Correct 852 ms 32852 KB Output is correct
21 Correct 852 ms 32852 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 3 ms 604 KB Output is correct
24 Correct 3 ms 604 KB Output is correct
25 Correct 3 ms 604 KB Output is correct
26 Correct 3 ms 604 KB Output is correct
27 Correct 3 ms 604 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 3 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 3 ms 604 KB Output is correct
33 Correct 3 ms 600 KB Output is correct
34 Correct 3 ms 604 KB Output is correct
35 Correct 3 ms 604 KB Output is correct
36 Incorrect 0 ms 348 KB Output isn't correct
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 460 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 756 ms 33904 KB Output is correct
27 Correct 770 ms 33700 KB Output is correct
28 Correct 752 ms 33872 KB Output is correct
29 Correct 776 ms 33732 KB Output is correct
30 Correct 809 ms 33856 KB Output is correct
31 Correct 827 ms 33836 KB Output is correct
32 Correct 812 ms 33816 KB Output is correct
33 Correct 802 ms 33864 KB Output is correct
34 Correct 800 ms 33876 KB Output is correct
35 Correct 836 ms 33872 KB Output is correct
36 Correct 806 ms 33708 KB Output is correct
37 Correct 747 ms 33876 KB Output is correct
38 Correct 788 ms 33864 KB Output is correct
39 Correct 806 ms 33692 KB Output is correct
40 Correct 819 ms 33876 KB Output is correct
41 Correct 801 ms 33736 KB Output is correct
42 Correct 832 ms 33648 KB Output is correct
43 Correct 762 ms 33732 KB Output is correct
44 Correct 774 ms 33876 KB Output is correct
45 Correct 736 ms 33624 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 838 ms 32704 KB Output is correct
48 Correct 775 ms 32704 KB Output is correct
49 Correct 816 ms 32704 KB Output is correct
50 Correct 807 ms 32852 KB Output is correct
51 Correct 825 ms 32840 KB Output is correct
52 Correct 785 ms 32916 KB Output is correct
53 Correct 793 ms 32732 KB Output is correct
54 Correct 839 ms 32920 KB Output is correct
55 Correct 808 ms 32948 KB Output is correct
56 Correct 813 ms 32836 KB Output is correct
57 Correct 803 ms 32848 KB Output is correct
58 Correct 801 ms 32852 KB Output is correct
59 Correct 835 ms 32744 KB Output is correct
60 Correct 829 ms 32848 KB Output is correct
61 Correct 862 ms 32812 KB Output is correct
62 Correct 852 ms 32864 KB Output is correct
63 Correct 830 ms 32748 KB Output is correct
64 Correct 828 ms 32848 KB Output is correct
65 Correct 852 ms 32852 KB Output is correct
66 Correct 852 ms 32852 KB Output is correct
67 Correct 0 ms 344 KB Output is correct
68 Correct 3 ms 604 KB Output is correct
69 Correct 3 ms 604 KB Output is correct
70 Correct 3 ms 604 KB Output is correct
71 Correct 3 ms 604 KB Output is correct
72 Correct 3 ms 604 KB Output is correct
73 Correct 3 ms 604 KB Output is correct
74 Correct 3 ms 604 KB Output is correct
75 Correct 3 ms 604 KB Output is correct
76 Correct 3 ms 604 KB Output is correct
77 Correct 3 ms 604 KB Output is correct
78 Correct 3 ms 600 KB Output is correct
79 Correct 3 ms 604 KB Output is correct
80 Correct 3 ms 604 KB Output is correct
81 Incorrect 0 ms 348 KB Output isn't correct
82 Halted 0 ms 0 KB -