답안 #1011982

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011982 2024-07-01T13:13:27 Z kaopj Cryptography (NOI20_crypto) C++17
100 / 100
259 ms 31640 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 int long long
#define orderedset tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#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;
    }
    int f[n];
    f[0]=1;
    for (int i=1;i<n;i++) {
        f[i]=i*f[i-1]%mod;
    }
    for (int i=n-1;i>=0;i--) {
        int l=s.order_of_key(num[i]);
        s.insert(num[i]);
        ans=(ans+f[n-i-1]*l%mod)%mod;
    }
    cout << (ans+1)%mod;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 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 0 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 0 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 344 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 253 ms 28496 KB Output is correct
3 Correct 248 ms 28496 KB Output is correct
4 Correct 259 ms 31312 KB Output is correct
5 Correct 246 ms 31460 KB Output is correct
6 Correct 241 ms 31312 KB Output is correct
7 Correct 231 ms 31316 KB Output is correct
8 Correct 225 ms 31432 KB Output is correct
9 Correct 222 ms 31572 KB Output is correct
10 Correct 221 ms 31316 KB Output is correct
11 Correct 214 ms 31488 KB Output is correct
12 Correct 245 ms 31432 KB Output is correct
13 Correct 251 ms 31348 KB Output is correct
14 Correct 236 ms 31328 KB Output is correct
15 Correct 215 ms 31304 KB Output is correct
16 Correct 210 ms 31312 KB Output is correct
17 Correct 230 ms 31304 KB Output is correct
18 Correct 216 ms 31312 KB Output is correct
19 Correct 226 ms 31312 KB Output is correct
20 Correct 255 ms 31572 KB Output is correct
21 Correct 242 ms 31328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 205 ms 30548 KB Output is correct
3 Correct 211 ms 30544 KB Output is correct
4 Correct 213 ms 30440 KB Output is correct
5 Correct 205 ms 30328 KB Output is correct
6 Correct 226 ms 30408 KB Output is correct
7 Correct 227 ms 30544 KB Output is correct
8 Correct 230 ms 30548 KB Output is correct
9 Correct 212 ms 30548 KB Output is correct
10 Correct 227 ms 30548 KB Output is correct
11 Correct 231 ms 30740 KB Output is correct
12 Correct 229 ms 30544 KB Output is correct
13 Correct 216 ms 30552 KB Output is correct
14 Correct 226 ms 30544 KB Output is correct
15 Correct 217 ms 30548 KB Output is correct
16 Correct 233 ms 30400 KB Output is correct
17 Correct 221 ms 30392 KB Output is correct
18 Correct 228 ms 30428 KB Output is correct
19 Correct 204 ms 30612 KB Output is correct
20 Correct 215 ms 30800 KB Output is correct
21 Correct 200 ms 30444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 564 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 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 0 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 0 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 344 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 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 1 ms 564 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 2 ms 604 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 604 KB Output is correct
41 Correct 1 ms 604 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 1 ms 604 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Correct 1 ms 604 KB Output is correct
46 Correct 1 ms 604 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 1 ms 604 KB Output is correct
49 Correct 1 ms 604 KB Output is correct
50 Correct 1 ms 604 KB Output is correct
51 Correct 2 ms 860 KB Output is correct
52 Correct 1 ms 604 KB Output is correct
53 Correct 1 ms 604 KB Output is correct
54 Correct 1 ms 604 KB Output is correct
55 Correct 1 ms 600 KB Output is correct
56 Correct 1 ms 604 KB Output is correct
57 Correct 1 ms 604 KB Output is correct
58 Correct 1 ms 604 KB Output is correct
59 Correct 1 ms 604 KB Output is correct
60 Correct 1 ms 604 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 1 ms 604 KB Output is correct
63 Correct 1 ms 604 KB Output is correct
64 Correct 1 ms 604 KB Output is correct
65 Correct 1 ms 604 KB Output is correct
66 Correct 1 ms 604 KB Output is correct
67 Correct 1 ms 604 KB Output is correct
68 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 205 ms 30548 KB Output is correct
3 Correct 211 ms 30544 KB Output is correct
4 Correct 213 ms 30440 KB Output is correct
5 Correct 205 ms 30328 KB Output is correct
6 Correct 226 ms 30408 KB Output is correct
7 Correct 227 ms 30544 KB Output is correct
8 Correct 230 ms 30548 KB Output is correct
9 Correct 212 ms 30548 KB Output is correct
10 Correct 227 ms 30548 KB Output is correct
11 Correct 231 ms 30740 KB Output is correct
12 Correct 229 ms 30544 KB Output is correct
13 Correct 216 ms 30552 KB Output is correct
14 Correct 226 ms 30544 KB Output is correct
15 Correct 217 ms 30548 KB Output is correct
16 Correct 233 ms 30400 KB Output is correct
17 Correct 221 ms 30392 KB Output is correct
18 Correct 228 ms 30428 KB Output is correct
19 Correct 204 ms 30612 KB Output is correct
20 Correct 215 ms 30800 KB Output is correct
21 Correct 200 ms 30444 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 1 ms 600 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 604 KB Output is correct
32 Correct 1 ms 564 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 604 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 1 ms 604 KB Output is correct
40 Correct 1 ms 604 KB Output is correct
41 Correct 1 ms 604 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 1 ms 604 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 196 ms 30448 KB Output is correct
46 Correct 189 ms 30424 KB Output is correct
47 Correct 185 ms 30544 KB Output is correct
48 Correct 191 ms 30432 KB Output is correct
49 Correct 191 ms 30548 KB Output is correct
50 Correct 189 ms 30548 KB Output is correct
51 Correct 203 ms 30700 KB Output is correct
52 Correct 189 ms 30436 KB Output is correct
53 Correct 191 ms 30548 KB Output is correct
54 Correct 190 ms 30352 KB Output is correct
55 Correct 194 ms 30420 KB Output is correct
56 Correct 186 ms 30544 KB Output is correct
57 Correct 178 ms 30548 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 224 ms 30520 KB Output is correct
60 Correct 190 ms 30544 KB Output is correct
61 Correct 190 ms 30316 KB Output is correct
62 Correct 185 ms 30548 KB Output is correct
63 Correct 164 ms 30544 KB Output is correct
64 Correct 192 ms 30548 KB Output is correct
65 Correct 173 ms 30436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 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 0 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 0 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 344 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 348 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 253 ms 28496 KB Output is correct
27 Correct 248 ms 28496 KB Output is correct
28 Correct 259 ms 31312 KB Output is correct
29 Correct 246 ms 31460 KB Output is correct
30 Correct 241 ms 31312 KB Output is correct
31 Correct 231 ms 31316 KB Output is correct
32 Correct 225 ms 31432 KB Output is correct
33 Correct 222 ms 31572 KB Output is correct
34 Correct 221 ms 31316 KB Output is correct
35 Correct 214 ms 31488 KB Output is correct
36 Correct 245 ms 31432 KB Output is correct
37 Correct 251 ms 31348 KB Output is correct
38 Correct 236 ms 31328 KB Output is correct
39 Correct 215 ms 31304 KB Output is correct
40 Correct 210 ms 31312 KB Output is correct
41 Correct 230 ms 31304 KB Output is correct
42 Correct 216 ms 31312 KB Output is correct
43 Correct 226 ms 31312 KB Output is correct
44 Correct 255 ms 31572 KB Output is correct
45 Correct 242 ms 31328 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 205 ms 30548 KB Output is correct
48 Correct 211 ms 30544 KB Output is correct
49 Correct 213 ms 30440 KB Output is correct
50 Correct 205 ms 30328 KB Output is correct
51 Correct 226 ms 30408 KB Output is correct
52 Correct 227 ms 30544 KB Output is correct
53 Correct 230 ms 30548 KB Output is correct
54 Correct 212 ms 30548 KB Output is correct
55 Correct 227 ms 30548 KB Output is correct
56 Correct 231 ms 30740 KB Output is correct
57 Correct 229 ms 30544 KB Output is correct
58 Correct 216 ms 30552 KB Output is correct
59 Correct 226 ms 30544 KB Output is correct
60 Correct 217 ms 30548 KB Output is correct
61 Correct 233 ms 30400 KB Output is correct
62 Correct 221 ms 30392 KB Output is correct
63 Correct 228 ms 30428 KB Output is correct
64 Correct 204 ms 30612 KB Output is correct
65 Correct 215 ms 30800 KB Output is correct
66 Correct 200 ms 30444 KB Output is correct
67 Correct 0 ms 344 KB Output is correct
68 Correct 1 ms 604 KB Output is correct
69 Correct 1 ms 604 KB Output is correct
70 Correct 1 ms 604 KB Output is correct
71 Correct 1 ms 604 KB Output is correct
72 Correct 1 ms 604 KB Output is correct
73 Correct 1 ms 600 KB Output is correct
74 Correct 1 ms 600 KB Output is correct
75 Correct 1 ms 604 KB Output is correct
76 Correct 1 ms 604 KB Output is correct
77 Correct 1 ms 564 KB Output is correct
78 Correct 1 ms 604 KB Output is correct
79 Correct 2 ms 604 KB Output is correct
80 Correct 1 ms 604 KB Output is correct
81 Correct 0 ms 348 KB Output is correct
82 Correct 1 ms 604 KB Output is correct
83 Correct 1 ms 604 KB Output is correct
84 Correct 1 ms 604 KB Output is correct
85 Correct 1 ms 604 KB Output is correct
86 Correct 1 ms 604 KB Output is correct
87 Correct 1 ms 604 KB Output is correct
88 Correct 1 ms 604 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 1 ms 604 KB Output is correct
91 Correct 1 ms 604 KB Output is correct
92 Correct 1 ms 604 KB Output is correct
93 Correct 2 ms 860 KB Output is correct
94 Correct 1 ms 604 KB Output is correct
95 Correct 1 ms 604 KB Output is correct
96 Correct 1 ms 604 KB Output is correct
97 Correct 1 ms 600 KB Output is correct
98 Correct 1 ms 604 KB Output is correct
99 Correct 1 ms 604 KB Output is correct
100 Correct 1 ms 604 KB Output is correct
101 Correct 1 ms 604 KB Output is correct
102 Correct 1 ms 604 KB Output is correct
103 Correct 0 ms 348 KB Output is correct
104 Correct 1 ms 604 KB Output is correct
105 Correct 1 ms 604 KB Output is correct
106 Correct 1 ms 604 KB Output is correct
107 Correct 1 ms 604 KB Output is correct
108 Correct 1 ms 604 KB Output is correct
109 Correct 1 ms 604 KB Output is correct
110 Correct 1 ms 600 KB Output is correct
111 Correct 0 ms 348 KB Output is correct
112 Correct 196 ms 30448 KB Output is correct
113 Correct 189 ms 30424 KB Output is correct
114 Correct 185 ms 30544 KB Output is correct
115 Correct 191 ms 30432 KB Output is correct
116 Correct 191 ms 30548 KB Output is correct
117 Correct 189 ms 30548 KB Output is correct
118 Correct 203 ms 30700 KB Output is correct
119 Correct 189 ms 30436 KB Output is correct
120 Correct 191 ms 30548 KB Output is correct
121 Correct 190 ms 30352 KB Output is correct
122 Correct 194 ms 30420 KB Output is correct
123 Correct 186 ms 30544 KB Output is correct
124 Correct 178 ms 30548 KB Output is correct
125 Correct 0 ms 348 KB Output is correct
126 Correct 224 ms 30520 KB Output is correct
127 Correct 190 ms 30544 KB Output is correct
128 Correct 190 ms 30316 KB Output is correct
129 Correct 185 ms 30548 KB Output is correct
130 Correct 164 ms 30544 KB Output is correct
131 Correct 192 ms 30548 KB Output is correct
132 Correct 173 ms 30436 KB Output is correct
133 Correct 0 ms 348 KB Output is correct
134 Correct 190 ms 31380 KB Output is correct
135 Correct 191 ms 31404 KB Output is correct
136 Correct 199 ms 31640 KB Output is correct
137 Correct 175 ms 31312 KB Output is correct
138 Correct 210 ms 31316 KB Output is correct
139 Correct 177 ms 31316 KB Output is correct
140 Correct 200 ms 31388 KB Output is correct
141 Correct 172 ms 31304 KB Output is correct
142 Correct 194 ms 31316 KB Output is correct
143 Correct 165 ms 31424 KB Output is correct
144 Correct 191 ms 31400 KB Output is correct
145 Correct 210 ms 31384 KB Output is correct
146 Correct 191 ms 31316 KB Output is correct
147 Correct 0 ms 344 KB Output is correct
148 Correct 179 ms 31376 KB Output is correct
149 Correct 198 ms 31408 KB Output is correct
150 Correct 191 ms 31408 KB Output is correct
151 Correct 182 ms 31392 KB Output is correct
152 Correct 178 ms 31300 KB Output is correct
153 Correct 172 ms 31396 KB Output is correct
154 Correct 175 ms 31312 KB Output is correct