Submission #973232

# Submission time Handle Problem Language Result Execution time Memory
973232 2024-05-01T16:32:13 Z njoop Cryptography (NOI20_crypto) C++17
100 / 100
328 ms 25076 KB
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#define ll long long

using namespace __gnu_pbds;
using namespace std;

int n, in, ord[300010], idx;
ll fac[300010], mod = 1e9+7, ans;
vector<pair<int, int>> v;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set s;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    fac[0] = 1;
    for(int i=1; i<300010; i++) {
        fac[i] = i*fac[i-1];
        fac[i] %= mod;
    }
    cin >> n;
    for(int i=1; i<=n; i++) {
        cin >> in;
        v.push_back({in, i});
    }
    sort(v.begin(), v.end());
    for(int i=0; i<v.size(); i++) {
        ord[v[i].second] = i;
    }
    for(int i=1; i<=n; i++) {
        idx = s.order_of_key(ord[i]);
        ans += ((ord[i]-idx)*fac[n-i])%mod;
        ans %= mod;
        s.insert(ord[i]);
    }
    cout << (ans+1)%mod;
    return 0;
}

Compilation message

Crypto.cpp: In function 'int main()':
Crypto.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=0; i<v.size(); i++) {
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2648 KB Output is correct
2 Correct 4 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2648 KB Output is correct
2 Correct 4 ms 2648 KB Output is correct
3 Correct 3 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 4 ms 2648 KB Output is correct
6 Correct 3 ms 2652 KB Output is correct
7 Correct 3 ms 2652 KB Output is correct
8 Correct 3 ms 2652 KB Output is correct
9 Correct 3 ms 2652 KB Output is correct
10 Correct 3 ms 2652 KB Output is correct
11 Correct 3 ms 2648 KB Output is correct
12 Correct 3 ms 2680 KB Output is correct
13 Correct 3 ms 2652 KB Output is correct
14 Correct 3 ms 2652 KB Output is correct
15 Correct 3 ms 2652 KB Output is correct
16 Correct 3 ms 2652 KB Output is correct
17 Correct 3 ms 2652 KB Output is correct
18 Correct 3 ms 2652 KB Output is correct
19 Correct 3 ms 2652 KB Output is correct
20 Correct 3 ms 2648 KB Output is correct
21 Correct 3 ms 2652 KB Output is correct
22 Correct 3 ms 2652 KB Output is correct
23 Correct 3 ms 2652 KB Output is correct
24 Correct 3 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2904 KB Output is correct
2 Correct 298 ms 20712 KB Output is correct
3 Correct 313 ms 20160 KB Output is correct
4 Correct 301 ms 21540 KB Output is correct
5 Correct 284 ms 20760 KB Output is correct
6 Correct 308 ms 20408 KB Output is correct
7 Correct 327 ms 20820 KB Output is correct
8 Correct 307 ms 21608 KB Output is correct
9 Correct 305 ms 21704 KB Output is correct
10 Correct 311 ms 21436 KB Output is correct
11 Correct 306 ms 21188 KB Output is correct
12 Correct 317 ms 21956 KB Output is correct
13 Correct 291 ms 20876 KB Output is correct
14 Correct 328 ms 21324 KB Output is correct
15 Correct 315 ms 21020 KB Output is correct
16 Correct 308 ms 21036 KB Output is correct
17 Correct 315 ms 21112 KB Output is correct
18 Correct 295 ms 20632 KB Output is correct
19 Correct 324 ms 21812 KB Output is correct
20 Correct 318 ms 22024 KB Output is correct
21 Correct 315 ms 21120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2648 KB Output is correct
2 Correct 266 ms 20412 KB Output is correct
3 Correct 216 ms 21952 KB Output is correct
4 Correct 293 ms 20924 KB Output is correct
5 Correct 259 ms 20604 KB Output is correct
6 Correct 225 ms 21168 KB Output is correct
7 Correct 220 ms 21104 KB Output is correct
8 Correct 302 ms 20748 KB Output is correct
9 Correct 291 ms 21196 KB Output is correct
10 Correct 260 ms 20244 KB Output is correct
11 Correct 235 ms 20620 KB Output is correct
12 Correct 219 ms 20928 KB Output is correct
13 Correct 258 ms 20392 KB Output is correct
14 Correct 230 ms 21696 KB Output is correct
15 Correct 252 ms 20812 KB Output is correct
16 Correct 251 ms 20924 KB Output is correct
17 Correct 248 ms 21464 KB Output is correct
18 Correct 234 ms 21260 KB Output is correct
19 Correct 224 ms 20416 KB Output is correct
20 Correct 219 ms 20508 KB Output is correct
21 Correct 244 ms 20660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2652 KB Output is correct
2 Correct 4 ms 2908 KB Output is correct
3 Correct 4 ms 2908 KB Output is correct
4 Correct 4 ms 2904 KB Output is correct
5 Correct 4 ms 2880 KB Output is correct
6 Correct 4 ms 2908 KB Output is correct
7 Correct 4 ms 2908 KB Output is correct
8 Correct 4 ms 2908 KB Output is correct
9 Correct 4 ms 2908 KB Output is correct
10 Correct 4 ms 2908 KB Output is correct
11 Correct 4 ms 2908 KB Output is correct
12 Correct 4 ms 2884 KB Output is correct
13 Correct 4 ms 2904 KB Output is correct
14 Correct 4 ms 2908 KB Output is correct
15 Correct 3 ms 2652 KB Output is correct
16 Correct 4 ms 2908 KB Output is correct
17 Correct 4 ms 2904 KB Output is correct
18 Correct 4 ms 2908 KB Output is correct
19 Correct 4 ms 2908 KB Output is correct
20 Correct 4 ms 2908 KB Output is correct
21 Correct 4 ms 2988 KB Output is correct
22 Correct 4 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2648 KB Output is correct
2 Correct 4 ms 2648 KB Output is correct
3 Correct 3 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 4 ms 2648 KB Output is correct
6 Correct 3 ms 2652 KB Output is correct
7 Correct 3 ms 2652 KB Output is correct
8 Correct 3 ms 2652 KB Output is correct
9 Correct 3 ms 2652 KB Output is correct
10 Correct 3 ms 2652 KB Output is correct
11 Correct 3 ms 2648 KB Output is correct
12 Correct 3 ms 2680 KB Output is correct
13 Correct 3 ms 2652 KB Output is correct
14 Correct 3 ms 2652 KB Output is correct
15 Correct 3 ms 2652 KB Output is correct
16 Correct 3 ms 2652 KB Output is correct
17 Correct 3 ms 2652 KB Output is correct
18 Correct 3 ms 2652 KB Output is correct
19 Correct 3 ms 2652 KB Output is correct
20 Correct 3 ms 2648 KB Output is correct
21 Correct 3 ms 2652 KB Output is correct
22 Correct 3 ms 2652 KB Output is correct
23 Correct 3 ms 2652 KB Output is correct
24 Correct 3 ms 2652 KB Output is correct
25 Correct 3 ms 2652 KB Output is correct
26 Correct 4 ms 2908 KB Output is correct
27 Correct 4 ms 2908 KB Output is correct
28 Correct 4 ms 2904 KB Output is correct
29 Correct 4 ms 2880 KB Output is correct
30 Correct 4 ms 2908 KB Output is correct
31 Correct 4 ms 2908 KB Output is correct
32 Correct 4 ms 2908 KB Output is correct
33 Correct 4 ms 2908 KB Output is correct
34 Correct 4 ms 2908 KB Output is correct
35 Correct 4 ms 2908 KB Output is correct
36 Correct 4 ms 2884 KB Output is correct
37 Correct 4 ms 2904 KB Output is correct
38 Correct 4 ms 2908 KB Output is correct
39 Correct 3 ms 2652 KB Output is correct
40 Correct 4 ms 2908 KB Output is correct
41 Correct 4 ms 2904 KB Output is correct
42 Correct 4 ms 2908 KB Output is correct
43 Correct 4 ms 2908 KB Output is correct
44 Correct 4 ms 2908 KB Output is correct
45 Correct 4 ms 2988 KB Output is correct
46 Correct 4 ms 2908 KB Output is correct
47 Correct 3 ms 2652 KB Output is correct
48 Correct 4 ms 2908 KB Output is correct
49 Correct 4 ms 2908 KB Output is correct
50 Correct 4 ms 2908 KB Output is correct
51 Correct 4 ms 2908 KB Output is correct
52 Correct 4 ms 2824 KB Output is correct
53 Correct 5 ms 2912 KB Output is correct
54 Correct 4 ms 2908 KB Output is correct
55 Correct 4 ms 2916 KB Output is correct
56 Correct 4 ms 2908 KB Output is correct
57 Correct 4 ms 2908 KB Output is correct
58 Correct 4 ms 2908 KB Output is correct
59 Correct 4 ms 2908 KB Output is correct
60 Correct 4 ms 2948 KB Output is correct
61 Correct 3 ms 2652 KB Output is correct
62 Correct 4 ms 2908 KB Output is correct
63 Correct 4 ms 2908 KB Output is correct
64 Correct 4 ms 2908 KB Output is correct
65 Correct 4 ms 2908 KB Output is correct
66 Correct 4 ms 2908 KB Output is correct
67 Correct 4 ms 2824 KB Output is correct
68 Correct 5 ms 2872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2648 KB Output is correct
2 Correct 266 ms 20412 KB Output is correct
3 Correct 216 ms 21952 KB Output is correct
4 Correct 293 ms 20924 KB Output is correct
5 Correct 259 ms 20604 KB Output is correct
6 Correct 225 ms 21168 KB Output is correct
7 Correct 220 ms 21104 KB Output is correct
8 Correct 302 ms 20748 KB Output is correct
9 Correct 291 ms 21196 KB Output is correct
10 Correct 260 ms 20244 KB Output is correct
11 Correct 235 ms 20620 KB Output is correct
12 Correct 219 ms 20928 KB Output is correct
13 Correct 258 ms 20392 KB Output is correct
14 Correct 230 ms 21696 KB Output is correct
15 Correct 252 ms 20812 KB Output is correct
16 Correct 251 ms 20924 KB Output is correct
17 Correct 248 ms 21464 KB Output is correct
18 Correct 234 ms 21260 KB Output is correct
19 Correct 224 ms 20416 KB Output is correct
20 Correct 219 ms 20508 KB Output is correct
21 Correct 244 ms 20660 KB Output is correct
22 Correct 3 ms 2652 KB Output is correct
23 Correct 4 ms 2908 KB Output is correct
24 Correct 4 ms 2908 KB Output is correct
25 Correct 4 ms 2904 KB Output is correct
26 Correct 4 ms 2880 KB Output is correct
27 Correct 4 ms 2908 KB Output is correct
28 Correct 4 ms 2908 KB Output is correct
29 Correct 4 ms 2908 KB Output is correct
30 Correct 4 ms 2908 KB Output is correct
31 Correct 4 ms 2908 KB Output is correct
32 Correct 4 ms 2908 KB Output is correct
33 Correct 4 ms 2884 KB Output is correct
34 Correct 4 ms 2904 KB Output is correct
35 Correct 4 ms 2908 KB Output is correct
36 Correct 3 ms 2652 KB Output is correct
37 Correct 4 ms 2908 KB Output is correct
38 Correct 4 ms 2904 KB Output is correct
39 Correct 4 ms 2908 KB Output is correct
40 Correct 4 ms 2908 KB Output is correct
41 Correct 4 ms 2908 KB Output is correct
42 Correct 4 ms 2988 KB Output is correct
43 Correct 4 ms 2908 KB Output is correct
44 Correct 3 ms 2652 KB Output is correct
45 Correct 191 ms 22604 KB Output is correct
46 Correct 195 ms 22976 KB Output is correct
47 Correct 192 ms 22464 KB Output is correct
48 Correct 201 ms 23484 KB Output is correct
49 Correct 184 ms 22204 KB Output is correct
50 Correct 189 ms 23024 KB Output is correct
51 Correct 186 ms 23632 KB Output is correct
52 Correct 246 ms 22204 KB Output is correct
53 Correct 184 ms 22716 KB Output is correct
54 Correct 214 ms 23484 KB Output is correct
55 Correct 187 ms 23292 KB Output is correct
56 Correct 193 ms 22332 KB Output is correct
57 Correct 235 ms 22304 KB Output is correct
58 Correct 3 ms 2648 KB Output is correct
59 Correct 199 ms 22912 KB Output is correct
60 Correct 218 ms 23216 KB Output is correct
61 Correct 176 ms 23016 KB Output is correct
62 Correct 209 ms 23452 KB Output is correct
63 Correct 225 ms 23232 KB Output is correct
64 Correct 183 ms 22376 KB Output is correct
65 Correct 209 ms 22260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2648 KB Output is correct
2 Correct 4 ms 2648 KB Output is correct
3 Correct 3 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 4 ms 2648 KB Output is correct
6 Correct 3 ms 2652 KB Output is correct
7 Correct 3 ms 2652 KB Output is correct
8 Correct 3 ms 2652 KB Output is correct
9 Correct 3 ms 2652 KB Output is correct
10 Correct 3 ms 2652 KB Output is correct
11 Correct 3 ms 2648 KB Output is correct
12 Correct 3 ms 2680 KB Output is correct
13 Correct 3 ms 2652 KB Output is correct
14 Correct 3 ms 2652 KB Output is correct
15 Correct 3 ms 2652 KB Output is correct
16 Correct 3 ms 2652 KB Output is correct
17 Correct 3 ms 2652 KB Output is correct
18 Correct 3 ms 2652 KB Output is correct
19 Correct 3 ms 2652 KB Output is correct
20 Correct 3 ms 2648 KB Output is correct
21 Correct 3 ms 2652 KB Output is correct
22 Correct 3 ms 2652 KB Output is correct
23 Correct 3 ms 2652 KB Output is correct
24 Correct 3 ms 2652 KB Output is correct
25 Correct 3 ms 2904 KB Output is correct
26 Correct 298 ms 20712 KB Output is correct
27 Correct 313 ms 20160 KB Output is correct
28 Correct 301 ms 21540 KB Output is correct
29 Correct 284 ms 20760 KB Output is correct
30 Correct 308 ms 20408 KB Output is correct
31 Correct 327 ms 20820 KB Output is correct
32 Correct 307 ms 21608 KB Output is correct
33 Correct 305 ms 21704 KB Output is correct
34 Correct 311 ms 21436 KB Output is correct
35 Correct 306 ms 21188 KB Output is correct
36 Correct 317 ms 21956 KB Output is correct
37 Correct 291 ms 20876 KB Output is correct
38 Correct 328 ms 21324 KB Output is correct
39 Correct 315 ms 21020 KB Output is correct
40 Correct 308 ms 21036 KB Output is correct
41 Correct 315 ms 21112 KB Output is correct
42 Correct 295 ms 20632 KB Output is correct
43 Correct 324 ms 21812 KB Output is correct
44 Correct 318 ms 22024 KB Output is correct
45 Correct 315 ms 21120 KB Output is correct
46 Correct 3 ms 2648 KB Output is correct
47 Correct 266 ms 20412 KB Output is correct
48 Correct 216 ms 21952 KB Output is correct
49 Correct 293 ms 20924 KB Output is correct
50 Correct 259 ms 20604 KB Output is correct
51 Correct 225 ms 21168 KB Output is correct
52 Correct 220 ms 21104 KB Output is correct
53 Correct 302 ms 20748 KB Output is correct
54 Correct 291 ms 21196 KB Output is correct
55 Correct 260 ms 20244 KB Output is correct
56 Correct 235 ms 20620 KB Output is correct
57 Correct 219 ms 20928 KB Output is correct
58 Correct 258 ms 20392 KB Output is correct
59 Correct 230 ms 21696 KB Output is correct
60 Correct 252 ms 20812 KB Output is correct
61 Correct 251 ms 20924 KB Output is correct
62 Correct 248 ms 21464 KB Output is correct
63 Correct 234 ms 21260 KB Output is correct
64 Correct 224 ms 20416 KB Output is correct
65 Correct 219 ms 20508 KB Output is correct
66 Correct 244 ms 20660 KB Output is correct
67 Correct 3 ms 2652 KB Output is correct
68 Correct 4 ms 2908 KB Output is correct
69 Correct 4 ms 2908 KB Output is correct
70 Correct 4 ms 2904 KB Output is correct
71 Correct 4 ms 2880 KB Output is correct
72 Correct 4 ms 2908 KB Output is correct
73 Correct 4 ms 2908 KB Output is correct
74 Correct 4 ms 2908 KB Output is correct
75 Correct 4 ms 2908 KB Output is correct
76 Correct 4 ms 2908 KB Output is correct
77 Correct 4 ms 2908 KB Output is correct
78 Correct 4 ms 2884 KB Output is correct
79 Correct 4 ms 2904 KB Output is correct
80 Correct 4 ms 2908 KB Output is correct
81 Correct 3 ms 2652 KB Output is correct
82 Correct 4 ms 2908 KB Output is correct
83 Correct 4 ms 2904 KB Output is correct
84 Correct 4 ms 2908 KB Output is correct
85 Correct 4 ms 2908 KB Output is correct
86 Correct 4 ms 2908 KB Output is correct
87 Correct 4 ms 2988 KB Output is correct
88 Correct 4 ms 2908 KB Output is correct
89 Correct 3 ms 2652 KB Output is correct
90 Correct 4 ms 2908 KB Output is correct
91 Correct 4 ms 2908 KB Output is correct
92 Correct 4 ms 2908 KB Output is correct
93 Correct 4 ms 2908 KB Output is correct
94 Correct 4 ms 2824 KB Output is correct
95 Correct 5 ms 2912 KB Output is correct
96 Correct 4 ms 2908 KB Output is correct
97 Correct 4 ms 2916 KB Output is correct
98 Correct 4 ms 2908 KB Output is correct
99 Correct 4 ms 2908 KB Output is correct
100 Correct 4 ms 2908 KB Output is correct
101 Correct 4 ms 2908 KB Output is correct
102 Correct 4 ms 2948 KB Output is correct
103 Correct 3 ms 2652 KB Output is correct
104 Correct 4 ms 2908 KB Output is correct
105 Correct 4 ms 2908 KB Output is correct
106 Correct 4 ms 2908 KB Output is correct
107 Correct 4 ms 2908 KB Output is correct
108 Correct 4 ms 2908 KB Output is correct
109 Correct 4 ms 2824 KB Output is correct
110 Correct 5 ms 2872 KB Output is correct
111 Correct 3 ms 2652 KB Output is correct
112 Correct 191 ms 22604 KB Output is correct
113 Correct 195 ms 22976 KB Output is correct
114 Correct 192 ms 22464 KB Output is correct
115 Correct 201 ms 23484 KB Output is correct
116 Correct 184 ms 22204 KB Output is correct
117 Correct 189 ms 23024 KB Output is correct
118 Correct 186 ms 23632 KB Output is correct
119 Correct 246 ms 22204 KB Output is correct
120 Correct 184 ms 22716 KB Output is correct
121 Correct 214 ms 23484 KB Output is correct
122 Correct 187 ms 23292 KB Output is correct
123 Correct 193 ms 22332 KB Output is correct
124 Correct 235 ms 22304 KB Output is correct
125 Correct 3 ms 2648 KB Output is correct
126 Correct 199 ms 22912 KB Output is correct
127 Correct 218 ms 23216 KB Output is correct
128 Correct 176 ms 23016 KB Output is correct
129 Correct 209 ms 23452 KB Output is correct
130 Correct 225 ms 23232 KB Output is correct
131 Correct 183 ms 22376 KB Output is correct
132 Correct 209 ms 22260 KB Output is correct
133 Correct 3 ms 2652 KB Output is correct
134 Correct 216 ms 24312 KB Output is correct
135 Correct 183 ms 24040 KB Output is correct
136 Correct 194 ms 25076 KB Output is correct
137 Correct 182 ms 23996 KB Output is correct
138 Correct 202 ms 24656 KB Output is correct
139 Correct 223 ms 23592 KB Output is correct
140 Correct 191 ms 24768 KB Output is correct
141 Correct 194 ms 23512 KB Output is correct
142 Correct 194 ms 23236 KB Output is correct
143 Correct 189 ms 24788 KB Output is correct
144 Correct 200 ms 24280 KB Output is correct
145 Correct 195 ms 24484 KB Output is correct
146 Correct 197 ms 23488 KB Output is correct
147 Correct 3 ms 2652 KB Output is correct
148 Correct 216 ms 24056 KB Output is correct
149 Correct 189 ms 23788 KB Output is correct
150 Correct 197 ms 24088 KB Output is correct
151 Correct 203 ms 23776 KB Output is correct
152 Correct 194 ms 23228 KB Output is correct
153 Correct 185 ms 23488 KB Output is correct
154 Correct 207 ms 24512 KB Output is correct