# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
492561 | 2021-12-08T00:48:36 Z | anonymous | Cryptography (NOI20_crypto) | C++14 | 96 ms | 9104 KB |
#include <iostream> #include <algorithm> #define MAXN 300005 #define LL long long #define MOD 1000000007 using namespace std; int N,P[MAXN], Lookup[MAXN]; LL fac[MAXN]={1}, ans; class Fenwick { int BIT[MAXN]; public: void upd(int x) { for (; x<=N; x+= x&(-x)) {BIT[x]++;} } int ask(int p) { int res = 0; for (; p>0; p-=p&(-p)) {res += BIT[p];} return res; } } FT; int main() { //freopen("cryptin.txt","r",stdin); scanf("%d",&N); for (LL i=1; i<=N; i++) { scanf("%d",&P[i]); Lookup[i] = P[i]; fac[i] = (i*fac[i-1]) % MOD; } sort(Lookup+1, Lookup+N+1); for (int i=1; i<=N; i++) { LL ord = lower_bound(Lookup+1, Lookup+N+1, P[i]) - Lookup; ans = (ans + fac[N-i]*(ord-1-FT.ask(ord))) % MOD; FT.upd(ord); } printf("%lld", ans+1); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 308 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 308 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 300 KB | Output is correct |
12 | Correct | 0 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 304 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
16 | Correct | 0 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 304 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 0 ms | 204 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 204 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 1 ms | 304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 69 ms | 8936 KB | Output is correct |
3 | Correct | 66 ms | 9044 KB | Output is correct |
4 | Correct | 71 ms | 8940 KB | Output is correct |
5 | Correct | 66 ms | 9028 KB | Output is correct |
6 | Correct | 74 ms | 9028 KB | Output is correct |
7 | Correct | 96 ms | 9028 KB | Output is correct |
8 | Correct | 70 ms | 9104 KB | Output is correct |
9 | Correct | 67 ms | 9008 KB | Output is correct |
10 | Correct | 65 ms | 8984 KB | Output is correct |
11 | Correct | 68 ms | 9028 KB | Output is correct |
12 | Correct | 72 ms | 9040 KB | Output is correct |
13 | Correct | 91 ms | 9004 KB | Output is correct |
14 | Correct | 66 ms | 9028 KB | Output is correct |
15 | Correct | 74 ms | 9004 KB | Output is correct |
16 | Correct | 68 ms | 9052 KB | Output is correct |
17 | Correct | 66 ms | 9004 KB | Output is correct |
18 | Correct | 96 ms | 8952 KB | Output is correct |
19 | Correct | 77 ms | 8960 KB | Output is correct |
20 | Correct | 68 ms | 8984 KB | Output is correct |
21 | Correct | 66 ms | 8972 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 308 KB | Output is correct |
2 | Correct | 64 ms | 7980 KB | Output is correct |
3 | Correct | 65 ms | 8044 KB | Output is correct |
4 | Correct | 68 ms | 7976 KB | Output is correct |
5 | Correct | 63 ms | 8100 KB | Output is correct |
6 | Correct | 60 ms | 8060 KB | Output is correct |
7 | Correct | 59 ms | 8004 KB | Output is correct |
8 | Correct | 79 ms | 7992 KB | Output is correct |
9 | Correct | 62 ms | 8092 KB | Output is correct |
10 | Correct | 60 ms | 8056 KB | Output is correct |
11 | Correct | 69 ms | 8008 KB | Output is correct |
12 | Correct | 63 ms | 8092 KB | Output is correct |
13 | Correct | 67 ms | 8036 KB | Output is correct |
14 | Correct | 63 ms | 7976 KB | Output is correct |
15 | Correct | 60 ms | 8044 KB | Output is correct |
16 | Correct | 62 ms | 8084 KB | Output is correct |
17 | Correct | 65 ms | 8044 KB | Output is correct |
18 | Correct | 62 ms | 8004 KB | Output is correct |
19 | Correct | 62 ms | 8072 KB | Output is correct |
20 | Correct | 67 ms | 8072 KB | Output is correct |
21 | Correct | 62 ms | 8068 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 320 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 2 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Incorrect | 0 ms | 204 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 308 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 308 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 300 KB | Output is correct |
12 | Correct | 0 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 304 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
16 | Correct | 0 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 304 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 0 ms | 204 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 204 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 1 ms | 304 KB | Output is correct |
25 | Correct | 0 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 320 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 1 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 332 KB | Output is correct |
34 | Correct | 2 ms | 332 KB | Output is correct |
35 | Correct | 1 ms | 332 KB | Output is correct |
36 | Correct | 1 ms | 332 KB | Output is correct |
37 | Correct | 2 ms | 332 KB | Output is correct |
38 | Correct | 1 ms | 332 KB | Output is correct |
39 | Incorrect | 0 ms | 204 KB | Output isn't correct |
40 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 308 KB | Output is correct |
2 | Correct | 64 ms | 7980 KB | Output is correct |
3 | Correct | 65 ms | 8044 KB | Output is correct |
4 | Correct | 68 ms | 7976 KB | Output is correct |
5 | Correct | 63 ms | 8100 KB | Output is correct |
6 | Correct | 60 ms | 8060 KB | Output is correct |
7 | Correct | 59 ms | 8004 KB | Output is correct |
8 | Correct | 79 ms | 7992 KB | Output is correct |
9 | Correct | 62 ms | 8092 KB | Output is correct |
10 | Correct | 60 ms | 8056 KB | Output is correct |
11 | Correct | 69 ms | 8008 KB | Output is correct |
12 | Correct | 63 ms | 8092 KB | Output is correct |
13 | Correct | 67 ms | 8036 KB | Output is correct |
14 | Correct | 63 ms | 7976 KB | Output is correct |
15 | Correct | 60 ms | 8044 KB | Output is correct |
16 | Correct | 62 ms | 8084 KB | Output is correct |
17 | Correct | 65 ms | 8044 KB | Output is correct |
18 | Correct | 62 ms | 8004 KB | Output is correct |
19 | Correct | 62 ms | 8072 KB | Output is correct |
20 | Correct | 67 ms | 8072 KB | Output is correct |
21 | Correct | 62 ms | 8068 KB | Output is correct |
22 | Correct | 0 ms | 204 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 1 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 1 ms | 320 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 2 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 332 KB | Output is correct |
34 | Correct | 2 ms | 332 KB | Output is correct |
35 | Correct | 1 ms | 332 KB | Output is correct |
36 | Incorrect | 0 ms | 204 KB | Output isn't correct |
37 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 308 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 308 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 300 KB | Output is correct |
12 | Correct | 0 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 304 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
16 | Correct | 0 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 304 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 0 ms | 204 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 204 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 1 ms | 304 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 69 ms | 8936 KB | Output is correct |
27 | Correct | 66 ms | 9044 KB | Output is correct |
28 | Correct | 71 ms | 8940 KB | Output is correct |
29 | Correct | 66 ms | 9028 KB | Output is correct |
30 | Correct | 74 ms | 9028 KB | Output is correct |
31 | Correct | 96 ms | 9028 KB | Output is correct |
32 | Correct | 70 ms | 9104 KB | Output is correct |
33 | Correct | 67 ms | 9008 KB | Output is correct |
34 | Correct | 65 ms | 8984 KB | Output is correct |
35 | Correct | 68 ms | 9028 KB | Output is correct |
36 | Correct | 72 ms | 9040 KB | Output is correct |
37 | Correct | 91 ms | 9004 KB | Output is correct |
38 | Correct | 66 ms | 9028 KB | Output is correct |
39 | Correct | 74 ms | 9004 KB | Output is correct |
40 | Correct | 68 ms | 9052 KB | Output is correct |
41 | Correct | 66 ms | 9004 KB | Output is correct |
42 | Correct | 96 ms | 8952 KB | Output is correct |
43 | Correct | 77 ms | 8960 KB | Output is correct |
44 | Correct | 68 ms | 8984 KB | Output is correct |
45 | Correct | 66 ms | 8972 KB | Output is correct |
46 | Correct | 0 ms | 308 KB | Output is correct |
47 | Correct | 64 ms | 7980 KB | Output is correct |
48 | Correct | 65 ms | 8044 KB | Output is correct |
49 | Correct | 68 ms | 7976 KB | Output is correct |
50 | Correct | 63 ms | 8100 KB | Output is correct |
51 | Correct | 60 ms | 8060 KB | Output is correct |
52 | Correct | 59 ms | 8004 KB | Output is correct |
53 | Correct | 79 ms | 7992 KB | Output is correct |
54 | Correct | 62 ms | 8092 KB | Output is correct |
55 | Correct | 60 ms | 8056 KB | Output is correct |
56 | Correct | 69 ms | 8008 KB | Output is correct |
57 | Correct | 63 ms | 8092 KB | Output is correct |
58 | Correct | 67 ms | 8036 KB | Output is correct |
59 | Correct | 63 ms | 7976 KB | Output is correct |
60 | Correct | 60 ms | 8044 KB | Output is correct |
61 | Correct | 62 ms | 8084 KB | Output is correct |
62 | Correct | 65 ms | 8044 KB | Output is correct |
63 | Correct | 62 ms | 8004 KB | Output is correct |
64 | Correct | 62 ms | 8072 KB | Output is correct |
65 | Correct | 67 ms | 8072 KB | Output is correct |
66 | Correct | 62 ms | 8068 KB | Output is correct |
67 | Correct | 0 ms | 204 KB | Output is correct |
68 | Correct | 1 ms | 332 KB | Output is correct |
69 | Correct | 1 ms | 332 KB | Output is correct |
70 | Correct | 1 ms | 332 KB | Output is correct |
71 | Correct | 1 ms | 320 KB | Output is correct |
72 | Correct | 1 ms | 332 KB | Output is correct |
73 | Correct | 1 ms | 332 KB | Output is correct |
74 | Correct | 1 ms | 332 KB | Output is correct |
75 | Correct | 1 ms | 332 KB | Output is correct |
76 | Correct | 2 ms | 332 KB | Output is correct |
77 | Correct | 1 ms | 332 KB | Output is correct |
78 | Correct | 1 ms | 332 KB | Output is correct |
79 | Correct | 2 ms | 332 KB | Output is correct |
80 | Correct | 1 ms | 332 KB | Output is correct |
81 | Incorrect | 0 ms | 204 KB | Output isn't correct |
82 | Halted | 0 ms | 0 KB | - |