Submission #903575

# Submission time Handle Problem Language Result Execution time Memory
903575 2024-01-11T08:51:31 Z pcc Cryptography (NOI20_crypto) C++14
100 / 100
401 ms 21196 KB
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>

tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> st;

const ll mod = 1e9+7;
const ll mxn = 3e5+10;
ll fac[mxn];
int arr[mxn];

inline ll mad(ll a,ll b){
	 a += b;
	 return a>=mod?a-mod:a;
}
inline ll mub(ll a,ll b){
	return mad(a,mod-b);
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	fac[0] = 1;
	for(int i = 1;i<mxn;i++)fac[i] = fac[i-1]*i%mod;
	int N;
	cin>>N;
	for(int i = 1;i<=N;i++){
		cin>>arr[i];
		st.insert(arr[i]);
	}
	ll ans = 0;
	for(int i = 1;i<=N;i++){
		ans = mad(ans,fac[N-i]*st.order_of_key(arr[i])%mod);
		st.erase(arr[i]);
	}
	cout<<mad(ans,1);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3672 KB Output is correct
2 Correct 3 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3672 KB Output is correct
2 Correct 3 ms 3676 KB Output is correct
3 Correct 3 ms 3672 KB Output is correct
4 Correct 2 ms 3676 KB Output is correct
5 Correct 2 ms 3676 KB Output is correct
6 Correct 2 ms 3676 KB Output is correct
7 Correct 3 ms 3676 KB Output is correct
8 Correct 3 ms 3676 KB Output is correct
9 Correct 2 ms 3672 KB Output is correct
10 Correct 2 ms 3676 KB Output is correct
11 Correct 2 ms 3680 KB Output is correct
12 Correct 3 ms 3800 KB Output is correct
13 Correct 2 ms 3676 KB Output is correct
14 Correct 2 ms 3688 KB Output is correct
15 Correct 2 ms 3688 KB Output is correct
16 Correct 2 ms 3812 KB Output is correct
17 Correct 3 ms 3676 KB Output is correct
18 Correct 2 ms 3676 KB Output is correct
19 Correct 2 ms 3672 KB Output is correct
20 Correct 3 ms 3604 KB Output is correct
21 Correct 3 ms 3920 KB Output is correct
22 Correct 3 ms 3672 KB Output is correct
23 Correct 3 ms 3672 KB Output is correct
24 Correct 2 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3676 KB Output is correct
2 Correct 212 ms 18024 KB Output is correct
3 Correct 214 ms 20876 KB Output is correct
4 Correct 222 ms 21196 KB Output is correct
5 Correct 227 ms 20956 KB Output is correct
6 Correct 226 ms 20956 KB Output is correct
7 Correct 221 ms 20832 KB Output is correct
8 Correct 228 ms 20820 KB Output is correct
9 Correct 222 ms 20780 KB Output is correct
10 Correct 218 ms 20824 KB Output is correct
11 Correct 230 ms 20816 KB Output is correct
12 Correct 219 ms 20784 KB Output is correct
13 Correct 218 ms 20748 KB Output is correct
14 Correct 214 ms 20720 KB Output is correct
15 Correct 221 ms 20784 KB Output is correct
16 Correct 228 ms 20820 KB Output is correct
17 Correct 230 ms 21020 KB Output is correct
18 Correct 226 ms 20812 KB Output is correct
19 Correct 219 ms 20816 KB Output is correct
20 Correct 215 ms 20924 KB Output is correct
21 Correct 212 ms 20876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3672 KB Output is correct
2 Correct 246 ms 18052 KB Output is correct
3 Correct 288 ms 19908 KB Output is correct
4 Correct 232 ms 19960 KB Output is correct
5 Correct 237 ms 19992 KB Output is correct
6 Correct 261 ms 19992 KB Output is correct
7 Correct 287 ms 20000 KB Output is correct
8 Correct 219 ms 19796 KB Output is correct
9 Correct 219 ms 19928 KB Output is correct
10 Correct 243 ms 19808 KB Output is correct
11 Correct 263 ms 19792 KB Output is correct
12 Correct 288 ms 19796 KB Output is correct
13 Correct 236 ms 19956 KB Output is correct
14 Correct 272 ms 19996 KB Output is correct
15 Correct 229 ms 19996 KB Output is correct
16 Correct 242 ms 19892 KB Output is correct
17 Correct 243 ms 19844 KB Output is correct
18 Correct 246 ms 19996 KB Output is correct
19 Correct 269 ms 19992 KB Output is correct
20 Correct 298 ms 19852 KB Output is correct
21 Correct 255 ms 20204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3672 KB Output is correct
2 Correct 3 ms 3932 KB Output is correct
3 Correct 4 ms 3932 KB Output is correct
4 Correct 4 ms 3788 KB Output is correct
5 Correct 4 ms 3932 KB Output is correct
6 Correct 4 ms 3932 KB Output is correct
7 Correct 4 ms 3928 KB Output is correct
8 Correct 3 ms 3932 KB Output is correct
9 Correct 3 ms 3788 KB Output is correct
10 Correct 4 ms 3928 KB Output is correct
11 Correct 4 ms 4088 KB Output is correct
12 Correct 4 ms 3932 KB Output is correct
13 Correct 4 ms 3940 KB Output is correct
14 Correct 4 ms 3820 KB Output is correct
15 Correct 2 ms 3688 KB Output is correct
16 Correct 4 ms 3944 KB Output is correct
17 Correct 4 ms 3820 KB Output is correct
18 Correct 3 ms 3932 KB Output is correct
19 Correct 3 ms 3824 KB Output is correct
20 Correct 4 ms 3932 KB Output is correct
21 Correct 4 ms 3816 KB Output is correct
22 Correct 4 ms 3824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3672 KB Output is correct
2 Correct 3 ms 3676 KB Output is correct
3 Correct 3 ms 3672 KB Output is correct
4 Correct 2 ms 3676 KB Output is correct
5 Correct 2 ms 3676 KB Output is correct
6 Correct 2 ms 3676 KB Output is correct
7 Correct 3 ms 3676 KB Output is correct
8 Correct 3 ms 3676 KB Output is correct
9 Correct 2 ms 3672 KB Output is correct
10 Correct 2 ms 3676 KB Output is correct
11 Correct 2 ms 3680 KB Output is correct
12 Correct 3 ms 3800 KB Output is correct
13 Correct 2 ms 3676 KB Output is correct
14 Correct 2 ms 3688 KB Output is correct
15 Correct 2 ms 3688 KB Output is correct
16 Correct 2 ms 3812 KB Output is correct
17 Correct 3 ms 3676 KB Output is correct
18 Correct 2 ms 3676 KB Output is correct
19 Correct 2 ms 3672 KB Output is correct
20 Correct 3 ms 3604 KB Output is correct
21 Correct 3 ms 3920 KB Output is correct
22 Correct 3 ms 3672 KB Output is correct
23 Correct 3 ms 3672 KB Output is correct
24 Correct 2 ms 3676 KB Output is correct
25 Correct 2 ms 3672 KB Output is correct
26 Correct 3 ms 3932 KB Output is correct
27 Correct 4 ms 3932 KB Output is correct
28 Correct 4 ms 3788 KB Output is correct
29 Correct 4 ms 3932 KB Output is correct
30 Correct 4 ms 3932 KB Output is correct
31 Correct 4 ms 3928 KB Output is correct
32 Correct 3 ms 3932 KB Output is correct
33 Correct 3 ms 3788 KB Output is correct
34 Correct 4 ms 3928 KB Output is correct
35 Correct 4 ms 4088 KB Output is correct
36 Correct 4 ms 3932 KB Output is correct
37 Correct 4 ms 3940 KB Output is correct
38 Correct 4 ms 3820 KB Output is correct
39 Correct 2 ms 3688 KB Output is correct
40 Correct 4 ms 3944 KB Output is correct
41 Correct 4 ms 3820 KB Output is correct
42 Correct 3 ms 3932 KB Output is correct
43 Correct 3 ms 3824 KB Output is correct
44 Correct 4 ms 3932 KB Output is correct
45 Correct 4 ms 3816 KB Output is correct
46 Correct 4 ms 3824 KB Output is correct
47 Correct 3 ms 3676 KB Output is correct
48 Correct 4 ms 3932 KB Output is correct
49 Correct 4 ms 3932 KB Output is correct
50 Correct 4 ms 3932 KB Output is correct
51 Correct 4 ms 3868 KB Output is correct
52 Correct 5 ms 3928 KB Output is correct
53 Correct 4 ms 3932 KB Output is correct
54 Correct 4 ms 3932 KB Output is correct
55 Correct 4 ms 3824 KB Output is correct
56 Correct 4 ms 3932 KB Output is correct
57 Correct 4 ms 3820 KB Output is correct
58 Correct 4 ms 3932 KB Output is correct
59 Correct 4 ms 3932 KB Output is correct
60 Correct 4 ms 3824 KB Output is correct
61 Correct 3 ms 3676 KB Output is correct
62 Correct 3 ms 3932 KB Output is correct
63 Correct 5 ms 3932 KB Output is correct
64 Correct 4 ms 3944 KB Output is correct
65 Correct 4 ms 3944 KB Output is correct
66 Correct 4 ms 3944 KB Output is correct
67 Correct 4 ms 4004 KB Output is correct
68 Correct 4 ms 3944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3672 KB Output is correct
2 Correct 246 ms 18052 KB Output is correct
3 Correct 288 ms 19908 KB Output is correct
4 Correct 232 ms 19960 KB Output is correct
5 Correct 237 ms 19992 KB Output is correct
6 Correct 261 ms 19992 KB Output is correct
7 Correct 287 ms 20000 KB Output is correct
8 Correct 219 ms 19796 KB Output is correct
9 Correct 219 ms 19928 KB Output is correct
10 Correct 243 ms 19808 KB Output is correct
11 Correct 263 ms 19792 KB Output is correct
12 Correct 288 ms 19796 KB Output is correct
13 Correct 236 ms 19956 KB Output is correct
14 Correct 272 ms 19996 KB Output is correct
15 Correct 229 ms 19996 KB Output is correct
16 Correct 242 ms 19892 KB Output is correct
17 Correct 243 ms 19844 KB Output is correct
18 Correct 246 ms 19996 KB Output is correct
19 Correct 269 ms 19992 KB Output is correct
20 Correct 298 ms 19852 KB Output is correct
21 Correct 255 ms 20204 KB Output is correct
22 Correct 2 ms 3672 KB Output is correct
23 Correct 3 ms 3932 KB Output is correct
24 Correct 4 ms 3932 KB Output is correct
25 Correct 4 ms 3788 KB Output is correct
26 Correct 4 ms 3932 KB Output is correct
27 Correct 4 ms 3932 KB Output is correct
28 Correct 4 ms 3928 KB Output is correct
29 Correct 3 ms 3932 KB Output is correct
30 Correct 3 ms 3788 KB Output is correct
31 Correct 4 ms 3928 KB Output is correct
32 Correct 4 ms 4088 KB Output is correct
33 Correct 4 ms 3932 KB Output is correct
34 Correct 4 ms 3940 KB Output is correct
35 Correct 4 ms 3820 KB Output is correct
36 Correct 2 ms 3688 KB Output is correct
37 Correct 4 ms 3944 KB Output is correct
38 Correct 4 ms 3820 KB Output is correct
39 Correct 3 ms 3932 KB Output is correct
40 Correct 3 ms 3824 KB Output is correct
41 Correct 4 ms 3932 KB Output is correct
42 Correct 4 ms 3816 KB Output is correct
43 Correct 4 ms 3824 KB Output is correct
44 Correct 3 ms 3672 KB Output is correct
45 Correct 341 ms 19800 KB Output is correct
46 Correct 322 ms 20164 KB Output is correct
47 Correct 334 ms 20172 KB Output is correct
48 Correct 301 ms 19996 KB Output is correct
49 Correct 367 ms 19996 KB Output is correct
50 Correct 387 ms 19996 KB Output is correct
51 Correct 302 ms 19996 KB Output is correct
52 Correct 318 ms 19996 KB Output is correct
53 Correct 369 ms 19844 KB Output is correct
54 Correct 376 ms 19960 KB Output is correct
55 Correct 288 ms 20052 KB Output is correct
56 Correct 255 ms 20028 KB Output is correct
57 Correct 299 ms 19996 KB Output is correct
58 Correct 2 ms 3676 KB Output is correct
59 Correct 300 ms 19772 KB Output is correct
60 Correct 275 ms 19956 KB Output is correct
61 Correct 250 ms 19996 KB Output is correct
62 Correct 270 ms 19792 KB Output is correct
63 Correct 293 ms 20136 KB Output is correct
64 Correct 302 ms 19924 KB Output is correct
65 Correct 321 ms 19812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3672 KB Output is correct
2 Correct 3 ms 3676 KB Output is correct
3 Correct 3 ms 3672 KB Output is correct
4 Correct 2 ms 3676 KB Output is correct
5 Correct 2 ms 3676 KB Output is correct
6 Correct 2 ms 3676 KB Output is correct
7 Correct 3 ms 3676 KB Output is correct
8 Correct 3 ms 3676 KB Output is correct
9 Correct 2 ms 3672 KB Output is correct
10 Correct 2 ms 3676 KB Output is correct
11 Correct 2 ms 3680 KB Output is correct
12 Correct 3 ms 3800 KB Output is correct
13 Correct 2 ms 3676 KB Output is correct
14 Correct 2 ms 3688 KB Output is correct
15 Correct 2 ms 3688 KB Output is correct
16 Correct 2 ms 3812 KB Output is correct
17 Correct 3 ms 3676 KB Output is correct
18 Correct 2 ms 3676 KB Output is correct
19 Correct 2 ms 3672 KB Output is correct
20 Correct 3 ms 3604 KB Output is correct
21 Correct 3 ms 3920 KB Output is correct
22 Correct 3 ms 3672 KB Output is correct
23 Correct 3 ms 3672 KB Output is correct
24 Correct 2 ms 3676 KB Output is correct
25 Correct 2 ms 3676 KB Output is correct
26 Correct 212 ms 18024 KB Output is correct
27 Correct 214 ms 20876 KB Output is correct
28 Correct 222 ms 21196 KB Output is correct
29 Correct 227 ms 20956 KB Output is correct
30 Correct 226 ms 20956 KB Output is correct
31 Correct 221 ms 20832 KB Output is correct
32 Correct 228 ms 20820 KB Output is correct
33 Correct 222 ms 20780 KB Output is correct
34 Correct 218 ms 20824 KB Output is correct
35 Correct 230 ms 20816 KB Output is correct
36 Correct 219 ms 20784 KB Output is correct
37 Correct 218 ms 20748 KB Output is correct
38 Correct 214 ms 20720 KB Output is correct
39 Correct 221 ms 20784 KB Output is correct
40 Correct 228 ms 20820 KB Output is correct
41 Correct 230 ms 21020 KB Output is correct
42 Correct 226 ms 20812 KB Output is correct
43 Correct 219 ms 20816 KB Output is correct
44 Correct 215 ms 20924 KB Output is correct
45 Correct 212 ms 20876 KB Output is correct
46 Correct 2 ms 3672 KB Output is correct
47 Correct 246 ms 18052 KB Output is correct
48 Correct 288 ms 19908 KB Output is correct
49 Correct 232 ms 19960 KB Output is correct
50 Correct 237 ms 19992 KB Output is correct
51 Correct 261 ms 19992 KB Output is correct
52 Correct 287 ms 20000 KB Output is correct
53 Correct 219 ms 19796 KB Output is correct
54 Correct 219 ms 19928 KB Output is correct
55 Correct 243 ms 19808 KB Output is correct
56 Correct 263 ms 19792 KB Output is correct
57 Correct 288 ms 19796 KB Output is correct
58 Correct 236 ms 19956 KB Output is correct
59 Correct 272 ms 19996 KB Output is correct
60 Correct 229 ms 19996 KB Output is correct
61 Correct 242 ms 19892 KB Output is correct
62 Correct 243 ms 19844 KB Output is correct
63 Correct 246 ms 19996 KB Output is correct
64 Correct 269 ms 19992 KB Output is correct
65 Correct 298 ms 19852 KB Output is correct
66 Correct 255 ms 20204 KB Output is correct
67 Correct 2 ms 3672 KB Output is correct
68 Correct 3 ms 3932 KB Output is correct
69 Correct 4 ms 3932 KB Output is correct
70 Correct 4 ms 3788 KB Output is correct
71 Correct 4 ms 3932 KB Output is correct
72 Correct 4 ms 3932 KB Output is correct
73 Correct 4 ms 3928 KB Output is correct
74 Correct 3 ms 3932 KB Output is correct
75 Correct 3 ms 3788 KB Output is correct
76 Correct 4 ms 3928 KB Output is correct
77 Correct 4 ms 4088 KB Output is correct
78 Correct 4 ms 3932 KB Output is correct
79 Correct 4 ms 3940 KB Output is correct
80 Correct 4 ms 3820 KB Output is correct
81 Correct 2 ms 3688 KB Output is correct
82 Correct 4 ms 3944 KB Output is correct
83 Correct 4 ms 3820 KB Output is correct
84 Correct 3 ms 3932 KB Output is correct
85 Correct 3 ms 3824 KB Output is correct
86 Correct 4 ms 3932 KB Output is correct
87 Correct 4 ms 3816 KB Output is correct
88 Correct 4 ms 3824 KB Output is correct
89 Correct 3 ms 3676 KB Output is correct
90 Correct 4 ms 3932 KB Output is correct
91 Correct 4 ms 3932 KB Output is correct
92 Correct 4 ms 3932 KB Output is correct
93 Correct 4 ms 3868 KB Output is correct
94 Correct 5 ms 3928 KB Output is correct
95 Correct 4 ms 3932 KB Output is correct
96 Correct 4 ms 3932 KB Output is correct
97 Correct 4 ms 3824 KB Output is correct
98 Correct 4 ms 3932 KB Output is correct
99 Correct 4 ms 3820 KB Output is correct
100 Correct 4 ms 3932 KB Output is correct
101 Correct 4 ms 3932 KB Output is correct
102 Correct 4 ms 3824 KB Output is correct
103 Correct 3 ms 3676 KB Output is correct
104 Correct 3 ms 3932 KB Output is correct
105 Correct 5 ms 3932 KB Output is correct
106 Correct 4 ms 3944 KB Output is correct
107 Correct 4 ms 3944 KB Output is correct
108 Correct 4 ms 3944 KB Output is correct
109 Correct 4 ms 4004 KB Output is correct
110 Correct 4 ms 3944 KB Output is correct
111 Correct 3 ms 3672 KB Output is correct
112 Correct 341 ms 19800 KB Output is correct
113 Correct 322 ms 20164 KB Output is correct
114 Correct 334 ms 20172 KB Output is correct
115 Correct 301 ms 19996 KB Output is correct
116 Correct 367 ms 19996 KB Output is correct
117 Correct 387 ms 19996 KB Output is correct
118 Correct 302 ms 19996 KB Output is correct
119 Correct 318 ms 19996 KB Output is correct
120 Correct 369 ms 19844 KB Output is correct
121 Correct 376 ms 19960 KB Output is correct
122 Correct 288 ms 20052 KB Output is correct
123 Correct 255 ms 20028 KB Output is correct
124 Correct 299 ms 19996 KB Output is correct
125 Correct 2 ms 3676 KB Output is correct
126 Correct 300 ms 19772 KB Output is correct
127 Correct 275 ms 19956 KB Output is correct
128 Correct 250 ms 19996 KB Output is correct
129 Correct 270 ms 19792 KB Output is correct
130 Correct 293 ms 20136 KB Output is correct
131 Correct 302 ms 19924 KB Output is correct
132 Correct 321 ms 19812 KB Output is correct
133 Correct 2 ms 3676 KB Output is correct
134 Correct 326 ms 20828 KB Output is correct
135 Correct 332 ms 20852 KB Output is correct
136 Correct 401 ms 20960 KB Output is correct
137 Correct 343 ms 20952 KB Output is correct
138 Correct 357 ms 20956 KB Output is correct
139 Correct 366 ms 20724 KB Output is correct
140 Correct 384 ms 20880 KB Output is correct
141 Correct 375 ms 20956 KB Output is correct
142 Correct 354 ms 20956 KB Output is correct
143 Correct 288 ms 20952 KB Output is correct
144 Correct 327 ms 20820 KB Output is correct
145 Correct 343 ms 21036 KB Output is correct
146 Correct 315 ms 20924 KB Output is correct
147 Correct 2 ms 3672 KB Output is correct
148 Correct 358 ms 20956 KB Output is correct
149 Correct 281 ms 20880 KB Output is correct
150 Correct 290 ms 20960 KB Output is correct
151 Correct 284 ms 20956 KB Output is correct
152 Correct 330 ms 20952 KB Output is correct
153 Correct 309 ms 21076 KB Output is correct
154 Correct 317 ms 20880 KB Output is correct