답안 #973099

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973099 2024-05-01T13:44:09 Z jadai007 Cryptography (NOI20_crypto) C++17
100 / 100
536 ms 43532 KB
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int mod = 1e9 + 7;
set<int> s;
map<int, int> mt;
int arr[300300], n, cnt = 1, fac[300300], fw[300300], ans = 1;

void update(int idx, int val){
    for(int i = idx; i<=n; i+=(i&-i)) fw[i]+=val;
}

int query(int idx){
    int sum = 0;
    for(int i = idx; i>0; i-=(i&-i)) sum+=fw[i];
    return sum;
}

int32_t main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n;
    fac[0] = 1;
    for(int i = 1; i<=n; ++i) fac[i] = (fac[i - 1]*i)%mod;
    for(int i = 1; i<=n; ++i) cin >> arr[i], s.insert(arr[i]);
    for(auto x:s) mt[x] = cnt++;
    for(int i = 1; i<=n; ++i){
        ans = (ans + fac[n - i]*(mt[arr[i]] - query(mt[arr[i]]) - 1)%mod)%mod;
        update(mt[arr[i]], 1);
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4696 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4564 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4448 KB Output is correct
2 Correct 222 ms 40280 KB Output is correct
3 Correct 221 ms 43100 KB Output is correct
4 Correct 234 ms 43264 KB Output is correct
5 Correct 217 ms 43088 KB Output is correct
6 Correct 216 ms 43088 KB Output is correct
7 Correct 214 ms 43216 KB Output is correct
8 Correct 218 ms 43092 KB Output is correct
9 Correct 214 ms 43272 KB Output is correct
10 Correct 214 ms 43092 KB Output is correct
11 Correct 212 ms 43080 KB Output is correct
12 Correct 217 ms 43336 KB Output is correct
13 Correct 215 ms 43272 KB Output is correct
14 Correct 215 ms 43168 KB Output is correct
15 Correct 218 ms 43100 KB Output is correct
16 Correct 212 ms 43272 KB Output is correct
17 Correct 212 ms 43276 KB Output is correct
18 Correct 217 ms 43532 KB Output is correct
19 Correct 217 ms 43188 KB Output is correct
20 Correct 221 ms 43092 KB Output is correct
21 Correct 226 ms 43244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 210 ms 40368 KB Output is correct
3 Correct 216 ms 42076 KB Output is correct
4 Correct 208 ms 42272 KB Output is correct
5 Correct 209 ms 42080 KB Output is correct
6 Correct 218 ms 42100 KB Output is correct
7 Correct 212 ms 42084 KB Output is correct
8 Correct 208 ms 42308 KB Output is correct
9 Correct 216 ms 42308 KB Output is correct
10 Correct 207 ms 42140 KB Output is correct
11 Correct 212 ms 42548 KB Output is correct
12 Correct 211 ms 42252 KB Output is correct
13 Correct 211 ms 42324 KB Output is correct
14 Correct 218 ms 42112 KB Output is correct
15 Correct 207 ms 42068 KB Output is correct
16 Correct 208 ms 42064 KB Output is correct
17 Correct 217 ms 42100 KB Output is correct
18 Correct 235 ms 42068 KB Output is correct
19 Correct 217 ms 42208 KB Output is correct
20 Correct 225 ms 42580 KB Output is correct
21 Correct 237 ms 42068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4700 KB Output is correct
3 Correct 2 ms 4700 KB Output is correct
4 Correct 2 ms 4700 KB Output is correct
5 Correct 2 ms 4700 KB Output is correct
6 Correct 3 ms 4700 KB Output is correct
7 Correct 3 ms 4708 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
10 Correct 2 ms 4940 KB Output is correct
11 Correct 2 ms 4848 KB Output is correct
12 Correct 2 ms 4700 KB Output is correct
13 Correct 3 ms 4700 KB Output is correct
14 Correct 2 ms 4700 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 2 ms 4700 KB Output is correct
17 Correct 2 ms 4832 KB Output is correct
18 Correct 3 ms 4700 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 2 ms 4744 KB Output is correct
21 Correct 3 ms 4700 KB Output is correct
22 Correct 2 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4696 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4564 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 2 ms 4700 KB Output is correct
27 Correct 2 ms 4700 KB Output is correct
28 Correct 2 ms 4700 KB Output is correct
29 Correct 2 ms 4700 KB Output is correct
30 Correct 3 ms 4700 KB Output is correct
31 Correct 3 ms 4708 KB Output is correct
32 Correct 2 ms 4700 KB Output is correct
33 Correct 2 ms 4700 KB Output is correct
34 Correct 2 ms 4940 KB Output is correct
35 Correct 2 ms 4848 KB Output is correct
36 Correct 2 ms 4700 KB Output is correct
37 Correct 3 ms 4700 KB Output is correct
38 Correct 2 ms 4700 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 2 ms 4700 KB Output is correct
41 Correct 2 ms 4832 KB Output is correct
42 Correct 3 ms 4700 KB Output is correct
43 Correct 3 ms 4700 KB Output is correct
44 Correct 2 ms 4744 KB Output is correct
45 Correct 3 ms 4700 KB Output is correct
46 Correct 2 ms 4700 KB Output is correct
47 Correct 1 ms 4444 KB Output is correct
48 Correct 3 ms 4952 KB Output is correct
49 Correct 2 ms 4956 KB Output is correct
50 Correct 2 ms 4956 KB Output is correct
51 Correct 2 ms 4956 KB Output is correct
52 Correct 3 ms 4840 KB Output is correct
53 Correct 2 ms 4940 KB Output is correct
54 Correct 3 ms 4956 KB Output is correct
55 Correct 3 ms 4960 KB Output is correct
56 Correct 2 ms 4848 KB Output is correct
57 Correct 3 ms 4940 KB Output is correct
58 Correct 2 ms 4960 KB Output is correct
59 Correct 3 ms 4956 KB Output is correct
60 Correct 2 ms 4956 KB Output is correct
61 Correct 1 ms 4440 KB Output is correct
62 Correct 2 ms 4956 KB Output is correct
63 Correct 3 ms 4952 KB Output is correct
64 Correct 3 ms 4956 KB Output is correct
65 Correct 2 ms 4956 KB Output is correct
66 Correct 3 ms 4956 KB Output is correct
67 Correct 2 ms 4960 KB Output is correct
68 Correct 3 ms 4960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 210 ms 40368 KB Output is correct
3 Correct 216 ms 42076 KB Output is correct
4 Correct 208 ms 42272 KB Output is correct
5 Correct 209 ms 42080 KB Output is correct
6 Correct 218 ms 42100 KB Output is correct
7 Correct 212 ms 42084 KB Output is correct
8 Correct 208 ms 42308 KB Output is correct
9 Correct 216 ms 42308 KB Output is correct
10 Correct 207 ms 42140 KB Output is correct
11 Correct 212 ms 42548 KB Output is correct
12 Correct 211 ms 42252 KB Output is correct
13 Correct 211 ms 42324 KB Output is correct
14 Correct 218 ms 42112 KB Output is correct
15 Correct 207 ms 42068 KB Output is correct
16 Correct 208 ms 42064 KB Output is correct
17 Correct 217 ms 42100 KB Output is correct
18 Correct 235 ms 42068 KB Output is correct
19 Correct 217 ms 42208 KB Output is correct
20 Correct 225 ms 42580 KB Output is correct
21 Correct 237 ms 42068 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 2 ms 4700 KB Output is correct
24 Correct 2 ms 4700 KB Output is correct
25 Correct 2 ms 4700 KB Output is correct
26 Correct 2 ms 4700 KB Output is correct
27 Correct 3 ms 4700 KB Output is correct
28 Correct 3 ms 4708 KB Output is correct
29 Correct 2 ms 4700 KB Output is correct
30 Correct 2 ms 4700 KB Output is correct
31 Correct 2 ms 4940 KB Output is correct
32 Correct 2 ms 4848 KB Output is correct
33 Correct 2 ms 4700 KB Output is correct
34 Correct 3 ms 4700 KB Output is correct
35 Correct 2 ms 4700 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 2 ms 4700 KB Output is correct
38 Correct 2 ms 4832 KB Output is correct
39 Correct 3 ms 4700 KB Output is correct
40 Correct 3 ms 4700 KB Output is correct
41 Correct 2 ms 4744 KB Output is correct
42 Correct 3 ms 4700 KB Output is correct
43 Correct 2 ms 4700 KB Output is correct
44 Correct 1 ms 4448 KB Output is correct
45 Correct 489 ms 42076 KB Output is correct
46 Correct 478 ms 42328 KB Output is correct
47 Correct 524 ms 42312 KB Output is correct
48 Correct 502 ms 42388 KB Output is correct
49 Correct 470 ms 42324 KB Output is correct
50 Correct 493 ms 42072 KB Output is correct
51 Correct 494 ms 42552 KB Output is correct
52 Correct 474 ms 42312 KB Output is correct
53 Correct 461 ms 42160 KB Output is correct
54 Correct 495 ms 42348 KB Output is correct
55 Correct 472 ms 42220 KB Output is correct
56 Correct 462 ms 42336 KB Output is correct
57 Correct 496 ms 42532 KB Output is correct
58 Correct 1 ms 4444 KB Output is correct
59 Correct 475 ms 42168 KB Output is correct
60 Correct 505 ms 42068 KB Output is correct
61 Correct 521 ms 42168 KB Output is correct
62 Correct 496 ms 42176 KB Output is correct
63 Correct 481 ms 42504 KB Output is correct
64 Correct 507 ms 42068 KB Output is correct
65 Correct 458 ms 42564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4696 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4564 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4448 KB Output is correct
26 Correct 222 ms 40280 KB Output is correct
27 Correct 221 ms 43100 KB Output is correct
28 Correct 234 ms 43264 KB Output is correct
29 Correct 217 ms 43088 KB Output is correct
30 Correct 216 ms 43088 KB Output is correct
31 Correct 214 ms 43216 KB Output is correct
32 Correct 218 ms 43092 KB Output is correct
33 Correct 214 ms 43272 KB Output is correct
34 Correct 214 ms 43092 KB Output is correct
35 Correct 212 ms 43080 KB Output is correct
36 Correct 217 ms 43336 KB Output is correct
37 Correct 215 ms 43272 KB Output is correct
38 Correct 215 ms 43168 KB Output is correct
39 Correct 218 ms 43100 KB Output is correct
40 Correct 212 ms 43272 KB Output is correct
41 Correct 212 ms 43276 KB Output is correct
42 Correct 217 ms 43532 KB Output is correct
43 Correct 217 ms 43188 KB Output is correct
44 Correct 221 ms 43092 KB Output is correct
45 Correct 226 ms 43244 KB Output is correct
46 Correct 1 ms 4440 KB Output is correct
47 Correct 210 ms 40368 KB Output is correct
48 Correct 216 ms 42076 KB Output is correct
49 Correct 208 ms 42272 KB Output is correct
50 Correct 209 ms 42080 KB Output is correct
51 Correct 218 ms 42100 KB Output is correct
52 Correct 212 ms 42084 KB Output is correct
53 Correct 208 ms 42308 KB Output is correct
54 Correct 216 ms 42308 KB Output is correct
55 Correct 207 ms 42140 KB Output is correct
56 Correct 212 ms 42548 KB Output is correct
57 Correct 211 ms 42252 KB Output is correct
58 Correct 211 ms 42324 KB Output is correct
59 Correct 218 ms 42112 KB Output is correct
60 Correct 207 ms 42068 KB Output is correct
61 Correct 208 ms 42064 KB Output is correct
62 Correct 217 ms 42100 KB Output is correct
63 Correct 235 ms 42068 KB Output is correct
64 Correct 217 ms 42208 KB Output is correct
65 Correct 225 ms 42580 KB Output is correct
66 Correct 237 ms 42068 KB Output is correct
67 Correct 1 ms 4444 KB Output is correct
68 Correct 2 ms 4700 KB Output is correct
69 Correct 2 ms 4700 KB Output is correct
70 Correct 2 ms 4700 KB Output is correct
71 Correct 2 ms 4700 KB Output is correct
72 Correct 3 ms 4700 KB Output is correct
73 Correct 3 ms 4708 KB Output is correct
74 Correct 2 ms 4700 KB Output is correct
75 Correct 2 ms 4700 KB Output is correct
76 Correct 2 ms 4940 KB Output is correct
77 Correct 2 ms 4848 KB Output is correct
78 Correct 2 ms 4700 KB Output is correct
79 Correct 3 ms 4700 KB Output is correct
80 Correct 2 ms 4700 KB Output is correct
81 Correct 1 ms 4444 KB Output is correct
82 Correct 2 ms 4700 KB Output is correct
83 Correct 2 ms 4832 KB Output is correct
84 Correct 3 ms 4700 KB Output is correct
85 Correct 3 ms 4700 KB Output is correct
86 Correct 2 ms 4744 KB Output is correct
87 Correct 3 ms 4700 KB Output is correct
88 Correct 2 ms 4700 KB Output is correct
89 Correct 1 ms 4444 KB Output is correct
90 Correct 3 ms 4952 KB Output is correct
91 Correct 2 ms 4956 KB Output is correct
92 Correct 2 ms 4956 KB Output is correct
93 Correct 2 ms 4956 KB Output is correct
94 Correct 3 ms 4840 KB Output is correct
95 Correct 2 ms 4940 KB Output is correct
96 Correct 3 ms 4956 KB Output is correct
97 Correct 3 ms 4960 KB Output is correct
98 Correct 2 ms 4848 KB Output is correct
99 Correct 3 ms 4940 KB Output is correct
100 Correct 2 ms 4960 KB Output is correct
101 Correct 3 ms 4956 KB Output is correct
102 Correct 2 ms 4956 KB Output is correct
103 Correct 1 ms 4440 KB Output is correct
104 Correct 2 ms 4956 KB Output is correct
105 Correct 3 ms 4952 KB Output is correct
106 Correct 3 ms 4956 KB Output is correct
107 Correct 2 ms 4956 KB Output is correct
108 Correct 3 ms 4956 KB Output is correct
109 Correct 2 ms 4960 KB Output is correct
110 Correct 3 ms 4960 KB Output is correct
111 Correct 1 ms 4448 KB Output is correct
112 Correct 489 ms 42076 KB Output is correct
113 Correct 478 ms 42328 KB Output is correct
114 Correct 524 ms 42312 KB Output is correct
115 Correct 502 ms 42388 KB Output is correct
116 Correct 470 ms 42324 KB Output is correct
117 Correct 493 ms 42072 KB Output is correct
118 Correct 494 ms 42552 KB Output is correct
119 Correct 474 ms 42312 KB Output is correct
120 Correct 461 ms 42160 KB Output is correct
121 Correct 495 ms 42348 KB Output is correct
122 Correct 472 ms 42220 KB Output is correct
123 Correct 462 ms 42336 KB Output is correct
124 Correct 496 ms 42532 KB Output is correct
125 Correct 1 ms 4444 KB Output is correct
126 Correct 475 ms 42168 KB Output is correct
127 Correct 505 ms 42068 KB Output is correct
128 Correct 521 ms 42168 KB Output is correct
129 Correct 496 ms 42176 KB Output is correct
130 Correct 481 ms 42504 KB Output is correct
131 Correct 507 ms 42068 KB Output is correct
132 Correct 458 ms 42564 KB Output is correct
133 Correct 1 ms 4440 KB Output is correct
134 Correct 485 ms 43364 KB Output is correct
135 Correct 474 ms 43328 KB Output is correct
136 Correct 471 ms 43088 KB Output is correct
137 Correct 465 ms 43168 KB Output is correct
138 Correct 467 ms 43272 KB Output is correct
139 Correct 480 ms 43280 KB Output is correct
140 Correct 467 ms 43272 KB Output is correct
141 Correct 536 ms 43148 KB Output is correct
142 Correct 504 ms 43460 KB Output is correct
143 Correct 440 ms 43180 KB Output is correct
144 Correct 435 ms 43356 KB Output is correct
145 Correct 470 ms 43348 KB Output is correct
146 Correct 452 ms 43092 KB Output is correct
147 Correct 1 ms 4696 KB Output is correct
148 Correct 474 ms 43232 KB Output is correct
149 Correct 490 ms 43364 KB Output is correct
150 Correct 460 ms 43092 KB Output is correct
151 Correct 499 ms 43276 KB Output is correct
152 Correct 466 ms 43232 KB Output is correct
153 Correct 460 ms 43272 KB Output is correct
154 Correct 489 ms 43272 KB Output is correct