Submission #255320

# Submission time Handle Problem Language Result Execution time Memory
255320 2020-07-31T17:29:34 Z model_code Cryptography (NOI20_crypto) C++17
100 / 100
440 ms 42744 KB
#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;
using stat_tree = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

struct result_t{
    stat_tree* tree;
    int ans;
    int fact;
};

constexpr int MOD = 1'000'000'007;

result_t solve(int n){
    if(n == 0) return {new stat_tree, 0, 1};
    int curr;
    cin>>curr;
    result_t res = solve(n - 1);
    int index = res.tree->order_of_key(curr);
    res.tree->insert(curr);
    res.ans = (int)((res.ans + (long long)index * res.fact) % MOD);
    res.fact = (int)((long long)res.fact * n % MOD);
    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin>>n;
    cout<<(solve(n).ans + 1) % MOD;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 317 ms 42616 KB Output is correct
3 Correct 324 ms 42744 KB Output is correct
4 Correct 323 ms 42616 KB Output is correct
5 Correct 333 ms 42616 KB Output is correct
6 Correct 325 ms 42696 KB Output is correct
7 Correct 292 ms 42616 KB Output is correct
8 Correct 301 ms 42616 KB Output is correct
9 Correct 304 ms 42616 KB Output is correct
10 Correct 307 ms 42616 KB Output is correct
11 Correct 301 ms 42644 KB Output is correct
12 Correct 333 ms 42616 KB Output is correct
13 Correct 384 ms 42616 KB Output is correct
14 Correct 327 ms 42696 KB Output is correct
15 Correct 301 ms 42636 KB Output is correct
16 Correct 309 ms 42616 KB Output is correct
17 Correct 302 ms 42616 KB Output is correct
18 Correct 303 ms 42616 KB Output is correct
19 Correct 342 ms 42616 KB Output is correct
20 Correct 334 ms 42616 KB Output is correct
21 Correct 329 ms 42616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 278 ms 42616 KB Output is correct
3 Correct 301 ms 42664 KB Output is correct
4 Correct 289 ms 42616 KB Output is correct
5 Correct 280 ms 42580 KB Output is correct
6 Correct 284 ms 42532 KB Output is correct
7 Correct 298 ms 42624 KB Output is correct
8 Correct 310 ms 42616 KB Output is correct
9 Correct 294 ms 42616 KB Output is correct
10 Correct 293 ms 42616 KB Output is correct
11 Correct 311 ms 42616 KB Output is correct
12 Correct 305 ms 42620 KB Output is correct
13 Correct 295 ms 42592 KB Output is correct
14 Correct 293 ms 42616 KB Output is correct
15 Correct 282 ms 42616 KB Output is correct
16 Correct 296 ms 42592 KB Output is correct
17 Correct 298 ms 42672 KB Output is correct
18 Correct 287 ms 42568 KB Output is correct
19 Correct 318 ms 42592 KB Output is correct
20 Correct 300 ms 42632 KB Output is correct
21 Correct 298 ms 42592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 2 ms 768 KB Output is correct
3 Correct 2 ms 768 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 2 ms 768 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 2 ms 768 KB Output is correct
12 Correct 2 ms 768 KB Output is correct
13 Correct 2 ms 768 KB Output is correct
14 Correct 2 ms 896 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 2 ms 768 KB Output is correct
17 Correct 2 ms 768 KB Output is correct
18 Correct 2 ms 768 KB Output is correct
19 Correct 2 ms 768 KB Output is correct
20 Correct 3 ms 768 KB Output is correct
21 Correct 2 ms 768 KB Output is correct
22 Correct 3 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
25 Correct 0 ms 384 KB Output is correct
26 Correct 2 ms 768 KB Output is correct
27 Correct 2 ms 768 KB Output is correct
28 Correct 2 ms 768 KB Output is correct
29 Correct 2 ms 768 KB Output is correct
30 Correct 2 ms 768 KB Output is correct
31 Correct 2 ms 768 KB Output is correct
32 Correct 2 ms 768 KB Output is correct
33 Correct 2 ms 768 KB Output is correct
34 Correct 2 ms 768 KB Output is correct
35 Correct 2 ms 768 KB Output is correct
36 Correct 2 ms 768 KB Output is correct
37 Correct 2 ms 768 KB Output is correct
38 Correct 2 ms 896 KB Output is correct
39 Correct 0 ms 384 KB Output is correct
40 Correct 2 ms 768 KB Output is correct
41 Correct 2 ms 768 KB Output is correct
42 Correct 2 ms 768 KB Output is correct
43 Correct 2 ms 768 KB Output is correct
44 Correct 3 ms 768 KB Output is correct
45 Correct 2 ms 768 KB Output is correct
46 Correct 3 ms 768 KB Output is correct
47 Correct 0 ms 384 KB Output is correct
48 Correct 2 ms 768 KB Output is correct
49 Correct 3 ms 768 KB Output is correct
50 Correct 3 ms 768 KB Output is correct
51 Correct 3 ms 768 KB Output is correct
52 Correct 3 ms 768 KB Output is correct
53 Correct 2 ms 768 KB Output is correct
54 Correct 2 ms 768 KB Output is correct
55 Correct 2 ms 768 KB Output is correct
56 Correct 2 ms 768 KB Output is correct
57 Correct 2 ms 768 KB Output is correct
58 Correct 2 ms 768 KB Output is correct
59 Correct 2 ms 768 KB Output is correct
60 Correct 2 ms 768 KB Output is correct
61 Correct 0 ms 384 KB Output is correct
62 Correct 2 ms 768 KB Output is correct
63 Correct 2 ms 768 KB Output is correct
64 Correct 3 ms 768 KB Output is correct
65 Correct 2 ms 768 KB Output is correct
66 Correct 2 ms 768 KB Output is correct
67 Correct 2 ms 768 KB Output is correct
68 Correct 2 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 278 ms 42616 KB Output is correct
3 Correct 301 ms 42664 KB Output is correct
4 Correct 289 ms 42616 KB Output is correct
5 Correct 280 ms 42580 KB Output is correct
6 Correct 284 ms 42532 KB Output is correct
7 Correct 298 ms 42624 KB Output is correct
8 Correct 310 ms 42616 KB Output is correct
9 Correct 294 ms 42616 KB Output is correct
10 Correct 293 ms 42616 KB Output is correct
11 Correct 311 ms 42616 KB Output is correct
12 Correct 305 ms 42620 KB Output is correct
13 Correct 295 ms 42592 KB Output is correct
14 Correct 293 ms 42616 KB Output is correct
15 Correct 282 ms 42616 KB Output is correct
16 Correct 296 ms 42592 KB Output is correct
17 Correct 298 ms 42672 KB Output is correct
18 Correct 287 ms 42568 KB Output is correct
19 Correct 318 ms 42592 KB Output is correct
20 Correct 300 ms 42632 KB Output is correct
21 Correct 298 ms 42592 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 2 ms 768 KB Output is correct
24 Correct 2 ms 768 KB Output is correct
25 Correct 2 ms 768 KB Output is correct
26 Correct 2 ms 768 KB Output is correct
27 Correct 2 ms 768 KB Output is correct
28 Correct 2 ms 768 KB Output is correct
29 Correct 2 ms 768 KB Output is correct
30 Correct 2 ms 768 KB Output is correct
31 Correct 2 ms 768 KB Output is correct
32 Correct 2 ms 768 KB Output is correct
33 Correct 2 ms 768 KB Output is correct
34 Correct 2 ms 768 KB Output is correct
35 Correct 2 ms 896 KB Output is correct
36 Correct 0 ms 384 KB Output is correct
37 Correct 2 ms 768 KB Output is correct
38 Correct 2 ms 768 KB Output is correct
39 Correct 2 ms 768 KB Output is correct
40 Correct 2 ms 768 KB Output is correct
41 Correct 3 ms 768 KB Output is correct
42 Correct 2 ms 768 KB Output is correct
43 Correct 3 ms 768 KB Output is correct
44 Correct 0 ms 384 KB Output is correct
45 Correct 313 ms 42524 KB Output is correct
46 Correct 345 ms 42560 KB Output is correct
47 Correct 390 ms 42616 KB Output is correct
48 Correct 440 ms 42560 KB Output is correct
49 Correct 369 ms 42616 KB Output is correct
50 Correct 345 ms 42616 KB Output is correct
51 Correct 347 ms 42548 KB Output is correct
52 Correct 355 ms 42596 KB Output is correct
53 Correct 349 ms 42576 KB Output is correct
54 Correct 324 ms 42624 KB Output is correct
55 Correct 321 ms 42616 KB Output is correct
56 Correct 316 ms 42632 KB Output is correct
57 Correct 310 ms 42584 KB Output is correct
58 Correct 1 ms 384 KB Output is correct
59 Correct 343 ms 42592 KB Output is correct
60 Correct 345 ms 42616 KB Output is correct
61 Correct 318 ms 42616 KB Output is correct
62 Correct 323 ms 42612 KB Output is correct
63 Correct 327 ms 42644 KB Output is correct
64 Correct 298 ms 42604 KB Output is correct
65 Correct 312 ms 42568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
25 Correct 0 ms 384 KB Output is correct
26 Correct 317 ms 42616 KB Output is correct
27 Correct 324 ms 42744 KB Output is correct
28 Correct 323 ms 42616 KB Output is correct
29 Correct 333 ms 42616 KB Output is correct
30 Correct 325 ms 42696 KB Output is correct
31 Correct 292 ms 42616 KB Output is correct
32 Correct 301 ms 42616 KB Output is correct
33 Correct 304 ms 42616 KB Output is correct
34 Correct 307 ms 42616 KB Output is correct
35 Correct 301 ms 42644 KB Output is correct
36 Correct 333 ms 42616 KB Output is correct
37 Correct 384 ms 42616 KB Output is correct
38 Correct 327 ms 42696 KB Output is correct
39 Correct 301 ms 42636 KB Output is correct
40 Correct 309 ms 42616 KB Output is correct
41 Correct 302 ms 42616 KB Output is correct
42 Correct 303 ms 42616 KB Output is correct
43 Correct 342 ms 42616 KB Output is correct
44 Correct 334 ms 42616 KB Output is correct
45 Correct 329 ms 42616 KB Output is correct
46 Correct 1 ms 384 KB Output is correct
47 Correct 278 ms 42616 KB Output is correct
48 Correct 301 ms 42664 KB Output is correct
49 Correct 289 ms 42616 KB Output is correct
50 Correct 280 ms 42580 KB Output is correct
51 Correct 284 ms 42532 KB Output is correct
52 Correct 298 ms 42624 KB Output is correct
53 Correct 310 ms 42616 KB Output is correct
54 Correct 294 ms 42616 KB Output is correct
55 Correct 293 ms 42616 KB Output is correct
56 Correct 311 ms 42616 KB Output is correct
57 Correct 305 ms 42620 KB Output is correct
58 Correct 295 ms 42592 KB Output is correct
59 Correct 293 ms 42616 KB Output is correct
60 Correct 282 ms 42616 KB Output is correct
61 Correct 296 ms 42592 KB Output is correct
62 Correct 298 ms 42672 KB Output is correct
63 Correct 287 ms 42568 KB Output is correct
64 Correct 318 ms 42592 KB Output is correct
65 Correct 300 ms 42632 KB Output is correct
66 Correct 298 ms 42592 KB Output is correct
67 Correct 0 ms 384 KB Output is correct
68 Correct 2 ms 768 KB Output is correct
69 Correct 2 ms 768 KB Output is correct
70 Correct 2 ms 768 KB Output is correct
71 Correct 2 ms 768 KB Output is correct
72 Correct 2 ms 768 KB Output is correct
73 Correct 2 ms 768 KB Output is correct
74 Correct 2 ms 768 KB Output is correct
75 Correct 2 ms 768 KB Output is correct
76 Correct 2 ms 768 KB Output is correct
77 Correct 2 ms 768 KB Output is correct
78 Correct 2 ms 768 KB Output is correct
79 Correct 2 ms 768 KB Output is correct
80 Correct 2 ms 896 KB Output is correct
81 Correct 0 ms 384 KB Output is correct
82 Correct 2 ms 768 KB Output is correct
83 Correct 2 ms 768 KB Output is correct
84 Correct 2 ms 768 KB Output is correct
85 Correct 2 ms 768 KB Output is correct
86 Correct 3 ms 768 KB Output is correct
87 Correct 2 ms 768 KB Output is correct
88 Correct 3 ms 768 KB Output is correct
89 Correct 0 ms 384 KB Output is correct
90 Correct 2 ms 768 KB Output is correct
91 Correct 3 ms 768 KB Output is correct
92 Correct 3 ms 768 KB Output is correct
93 Correct 3 ms 768 KB Output is correct
94 Correct 3 ms 768 KB Output is correct
95 Correct 2 ms 768 KB Output is correct
96 Correct 2 ms 768 KB Output is correct
97 Correct 2 ms 768 KB Output is correct
98 Correct 2 ms 768 KB Output is correct
99 Correct 2 ms 768 KB Output is correct
100 Correct 2 ms 768 KB Output is correct
101 Correct 2 ms 768 KB Output is correct
102 Correct 2 ms 768 KB Output is correct
103 Correct 0 ms 384 KB Output is correct
104 Correct 2 ms 768 KB Output is correct
105 Correct 2 ms 768 KB Output is correct
106 Correct 3 ms 768 KB Output is correct
107 Correct 2 ms 768 KB Output is correct
108 Correct 2 ms 768 KB Output is correct
109 Correct 2 ms 768 KB Output is correct
110 Correct 2 ms 768 KB Output is correct
111 Correct 0 ms 384 KB Output is correct
112 Correct 313 ms 42524 KB Output is correct
113 Correct 345 ms 42560 KB Output is correct
114 Correct 390 ms 42616 KB Output is correct
115 Correct 440 ms 42560 KB Output is correct
116 Correct 369 ms 42616 KB Output is correct
117 Correct 345 ms 42616 KB Output is correct
118 Correct 347 ms 42548 KB Output is correct
119 Correct 355 ms 42596 KB Output is correct
120 Correct 349 ms 42576 KB Output is correct
121 Correct 324 ms 42624 KB Output is correct
122 Correct 321 ms 42616 KB Output is correct
123 Correct 316 ms 42632 KB Output is correct
124 Correct 310 ms 42584 KB Output is correct
125 Correct 1 ms 384 KB Output is correct
126 Correct 343 ms 42592 KB Output is correct
127 Correct 345 ms 42616 KB Output is correct
128 Correct 318 ms 42616 KB Output is correct
129 Correct 323 ms 42612 KB Output is correct
130 Correct 327 ms 42644 KB Output is correct
131 Correct 298 ms 42604 KB Output is correct
132 Correct 312 ms 42568 KB Output is correct
133 Correct 0 ms 384 KB Output is correct
134 Correct 339 ms 42640 KB Output is correct
135 Correct 332 ms 42616 KB Output is correct
136 Correct 328 ms 42580 KB Output is correct
137 Correct 327 ms 42616 KB Output is correct
138 Correct 305 ms 42616 KB Output is correct
139 Correct 367 ms 42628 KB Output is correct
140 Correct 341 ms 42612 KB Output is correct
141 Correct 334 ms 42576 KB Output is correct
142 Correct 336 ms 42616 KB Output is correct
143 Correct 373 ms 42620 KB Output is correct
144 Correct 356 ms 42628 KB Output is correct
145 Correct 371 ms 42644 KB Output is correct
146 Correct 366 ms 42600 KB Output is correct
147 Correct 0 ms 384 KB Output is correct
148 Correct 337 ms 42632 KB Output is correct
149 Correct 312 ms 42680 KB Output is correct
150 Correct 359 ms 42592 KB Output is correct
151 Correct 340 ms 42584 KB Output is correct
152 Correct 347 ms 42604 KB Output is correct
153 Correct 339 ms 42616 KB Output is correct
154 Correct 333 ms 42564 KB Output is correct