Submission #739997

# Submission time Handle Problem Language Result Execution time Memory
739997 2023-05-11T20:37:49 Z bane Cryptography (NOI20_crypto) C++17
100 / 100
319 ms 32340 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
const int MOD = (int)1e9 + 7;
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxN = (int)1e6+1;
class Solution{

	private:
	int N, P[maxN];
	public:
	void init(){
		cin >> N;
		for(int i = 0; i < N; i++){
			cin >> P[i];
		}
	}
	
	int Solve(){
		int ans = 1;
		Tree<int>t;
		int fact[N+1];
		fact[0]=1;
		for (int i = 1; i<=N; i++){
			fact[i] = (fact[i - 1] * i)%MOD;
		}
		for (int i = N - 1; i >= 0; i--){
			t.insert(P[i]);
			int pos = t.order_of_key(P[i]);
			ans = (ans + pos * fact[N - i  - 1])%MOD;
		}
		return ans;
	}

};

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	Solution resenie;
	resenie.init();
	cout<<resenie.Solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8020 KB Output is correct
2 Correct 4 ms 8020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8020 KB Output is correct
2 Correct 4 ms 8020 KB Output is correct
3 Correct 3 ms 8020 KB Output is correct
4 Correct 4 ms 8148 KB Output is correct
5 Correct 4 ms 8020 KB Output is correct
6 Correct 4 ms 8020 KB Output is correct
7 Correct 4 ms 8020 KB Output is correct
8 Correct 4 ms 8148 KB Output is correct
9 Correct 4 ms 8020 KB Output is correct
10 Correct 6 ms 8020 KB Output is correct
11 Correct 4 ms 8148 KB Output is correct
12 Correct 4 ms 8020 KB Output is correct
13 Correct 4 ms 8048 KB Output is correct
14 Correct 4 ms 8020 KB Output is correct
15 Correct 4 ms 8020 KB Output is correct
16 Correct 4 ms 8196 KB Output is correct
17 Correct 4 ms 8036 KB Output is correct
18 Correct 4 ms 8020 KB Output is correct
19 Correct 5 ms 8020 KB Output is correct
20 Correct 4 ms 8020 KB Output is correct
21 Correct 4 ms 8020 KB Output is correct
22 Correct 5 ms 8020 KB Output is correct
23 Correct 4 ms 8028 KB Output is correct
24 Correct 4 ms 8020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8020 KB Output is correct
2 Correct 268 ms 31564 KB Output is correct
3 Correct 256 ms 32180 KB Output is correct
4 Correct 256 ms 32060 KB Output is correct
5 Correct 256 ms 32148 KB Output is correct
6 Correct 269 ms 32056 KB Output is correct
7 Correct 233 ms 32100 KB Output is correct
8 Correct 231 ms 32044 KB Output is correct
9 Correct 229 ms 32056 KB Output is correct
10 Correct 224 ms 32140 KB Output is correct
11 Correct 231 ms 32052 KB Output is correct
12 Correct 271 ms 32072 KB Output is correct
13 Correct 258 ms 32076 KB Output is correct
14 Correct 259 ms 32104 KB Output is correct
15 Correct 225 ms 32184 KB Output is correct
16 Correct 230 ms 32140 KB Output is correct
17 Correct 243 ms 32060 KB Output is correct
18 Correct 230 ms 32084 KB Output is correct
19 Correct 304 ms 32176 KB Output is correct
20 Correct 252 ms 32140 KB Output is correct
21 Correct 263 ms 32188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8020 KB Output is correct
2 Correct 220 ms 31160 KB Output is correct
3 Correct 223 ms 31132 KB Output is correct
4 Correct 231 ms 31156 KB Output is correct
5 Correct 219 ms 31124 KB Output is correct
6 Correct 212 ms 31176 KB Output is correct
7 Correct 230 ms 31276 KB Output is correct
8 Correct 218 ms 31208 KB Output is correct
9 Correct 216 ms 31160 KB Output is correct
10 Correct 225 ms 31192 KB Output is correct
11 Correct 214 ms 31252 KB Output is correct
12 Correct 217 ms 31100 KB Output is correct
13 Correct 219 ms 31128 KB Output is correct
14 Correct 221 ms 31188 KB Output is correct
15 Correct 243 ms 31084 KB Output is correct
16 Correct 222 ms 31200 KB Output is correct
17 Correct 216 ms 31164 KB Output is correct
18 Correct 217 ms 31200 KB Output is correct
19 Correct 223 ms 31256 KB Output is correct
20 Correct 224 ms 31156 KB Output is correct
21 Correct 238 ms 31088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8140 KB Output is correct
2 Correct 6 ms 8336 KB Output is correct
3 Correct 5 ms 8284 KB Output is correct
4 Correct 5 ms 8276 KB Output is correct
5 Correct 4 ms 8276 KB Output is correct
6 Correct 5 ms 8276 KB Output is correct
7 Correct 5 ms 8284 KB Output is correct
8 Correct 5 ms 8284 KB Output is correct
9 Correct 6 ms 8276 KB Output is correct
10 Correct 5 ms 8288 KB Output is correct
11 Correct 5 ms 8276 KB Output is correct
12 Correct 6 ms 8280 KB Output is correct
13 Correct 7 ms 8276 KB Output is correct
14 Correct 6 ms 8276 KB Output is correct
15 Correct 4 ms 8148 KB Output is correct
16 Correct 5 ms 8276 KB Output is correct
17 Correct 5 ms 8276 KB Output is correct
18 Correct 5 ms 8276 KB Output is correct
19 Correct 5 ms 8276 KB Output is correct
20 Correct 4 ms 8276 KB Output is correct
21 Correct 4 ms 8276 KB Output is correct
22 Correct 6 ms 8280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8020 KB Output is correct
2 Correct 4 ms 8020 KB Output is correct
3 Correct 3 ms 8020 KB Output is correct
4 Correct 4 ms 8148 KB Output is correct
5 Correct 4 ms 8020 KB Output is correct
6 Correct 4 ms 8020 KB Output is correct
7 Correct 4 ms 8020 KB Output is correct
8 Correct 4 ms 8148 KB Output is correct
9 Correct 4 ms 8020 KB Output is correct
10 Correct 6 ms 8020 KB Output is correct
11 Correct 4 ms 8148 KB Output is correct
12 Correct 4 ms 8020 KB Output is correct
13 Correct 4 ms 8048 KB Output is correct
14 Correct 4 ms 8020 KB Output is correct
15 Correct 4 ms 8020 KB Output is correct
16 Correct 4 ms 8196 KB Output is correct
17 Correct 4 ms 8036 KB Output is correct
18 Correct 4 ms 8020 KB Output is correct
19 Correct 5 ms 8020 KB Output is correct
20 Correct 4 ms 8020 KB Output is correct
21 Correct 4 ms 8020 KB Output is correct
22 Correct 5 ms 8020 KB Output is correct
23 Correct 4 ms 8028 KB Output is correct
24 Correct 4 ms 8020 KB Output is correct
25 Correct 5 ms 8140 KB Output is correct
26 Correct 6 ms 8336 KB Output is correct
27 Correct 5 ms 8284 KB Output is correct
28 Correct 5 ms 8276 KB Output is correct
29 Correct 4 ms 8276 KB Output is correct
30 Correct 5 ms 8276 KB Output is correct
31 Correct 5 ms 8284 KB Output is correct
32 Correct 5 ms 8284 KB Output is correct
33 Correct 6 ms 8276 KB Output is correct
34 Correct 5 ms 8288 KB Output is correct
35 Correct 5 ms 8276 KB Output is correct
36 Correct 6 ms 8280 KB Output is correct
37 Correct 7 ms 8276 KB Output is correct
38 Correct 6 ms 8276 KB Output is correct
39 Correct 4 ms 8148 KB Output is correct
40 Correct 5 ms 8276 KB Output is correct
41 Correct 5 ms 8276 KB Output is correct
42 Correct 5 ms 8276 KB Output is correct
43 Correct 5 ms 8276 KB Output is correct
44 Correct 4 ms 8276 KB Output is correct
45 Correct 4 ms 8276 KB Output is correct
46 Correct 6 ms 8280 KB Output is correct
47 Correct 4 ms 8020 KB Output is correct
48 Correct 5 ms 8276 KB Output is correct
49 Correct 5 ms 8284 KB Output is correct
50 Correct 5 ms 8276 KB Output is correct
51 Correct 5 ms 8276 KB Output is correct
52 Correct 6 ms 8276 KB Output is correct
53 Correct 5 ms 8276 KB Output is correct
54 Correct 6 ms 8276 KB Output is correct
55 Correct 5 ms 8308 KB Output is correct
56 Correct 5 ms 8276 KB Output is correct
57 Correct 5 ms 8276 KB Output is correct
58 Correct 5 ms 8280 KB Output is correct
59 Correct 5 ms 8276 KB Output is correct
60 Correct 5 ms 8276 KB Output is correct
61 Correct 4 ms 8140 KB Output is correct
62 Correct 5 ms 8304 KB Output is correct
63 Correct 5 ms 8276 KB Output is correct
64 Correct 5 ms 8276 KB Output is correct
65 Correct 5 ms 8284 KB Output is correct
66 Correct 5 ms 8272 KB Output is correct
67 Correct 5 ms 8276 KB Output is correct
68 Correct 5 ms 8276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8020 KB Output is correct
2 Correct 220 ms 31160 KB Output is correct
3 Correct 223 ms 31132 KB Output is correct
4 Correct 231 ms 31156 KB Output is correct
5 Correct 219 ms 31124 KB Output is correct
6 Correct 212 ms 31176 KB Output is correct
7 Correct 230 ms 31276 KB Output is correct
8 Correct 218 ms 31208 KB Output is correct
9 Correct 216 ms 31160 KB Output is correct
10 Correct 225 ms 31192 KB Output is correct
11 Correct 214 ms 31252 KB Output is correct
12 Correct 217 ms 31100 KB Output is correct
13 Correct 219 ms 31128 KB Output is correct
14 Correct 221 ms 31188 KB Output is correct
15 Correct 243 ms 31084 KB Output is correct
16 Correct 222 ms 31200 KB Output is correct
17 Correct 216 ms 31164 KB Output is correct
18 Correct 217 ms 31200 KB Output is correct
19 Correct 223 ms 31256 KB Output is correct
20 Correct 224 ms 31156 KB Output is correct
21 Correct 238 ms 31088 KB Output is correct
22 Correct 5 ms 8140 KB Output is correct
23 Correct 6 ms 8336 KB Output is correct
24 Correct 5 ms 8284 KB Output is correct
25 Correct 5 ms 8276 KB Output is correct
26 Correct 4 ms 8276 KB Output is correct
27 Correct 5 ms 8276 KB Output is correct
28 Correct 5 ms 8284 KB Output is correct
29 Correct 5 ms 8284 KB Output is correct
30 Correct 6 ms 8276 KB Output is correct
31 Correct 5 ms 8288 KB Output is correct
32 Correct 5 ms 8276 KB Output is correct
33 Correct 6 ms 8280 KB Output is correct
34 Correct 7 ms 8276 KB Output is correct
35 Correct 6 ms 8276 KB Output is correct
36 Correct 4 ms 8148 KB Output is correct
37 Correct 5 ms 8276 KB Output is correct
38 Correct 5 ms 8276 KB Output is correct
39 Correct 5 ms 8276 KB Output is correct
40 Correct 5 ms 8276 KB Output is correct
41 Correct 4 ms 8276 KB Output is correct
42 Correct 4 ms 8276 KB Output is correct
43 Correct 6 ms 8280 KB Output is correct
44 Correct 5 ms 8020 KB Output is correct
45 Correct 257 ms 31156 KB Output is correct
46 Correct 259 ms 31192 KB Output is correct
47 Correct 291 ms 31200 KB Output is correct
48 Correct 262 ms 31112 KB Output is correct
49 Correct 258 ms 31204 KB Output is correct
50 Correct 261 ms 31084 KB Output is correct
51 Correct 263 ms 31264 KB Output is correct
52 Correct 279 ms 31100 KB Output is correct
53 Correct 262 ms 31252 KB Output is correct
54 Correct 297 ms 31152 KB Output is correct
55 Correct 258 ms 31368 KB Output is correct
56 Correct 291 ms 31180 KB Output is correct
57 Correct 263 ms 31156 KB Output is correct
58 Correct 4 ms 8020 KB Output is correct
59 Correct 319 ms 31132 KB Output is correct
60 Correct 271 ms 31132 KB Output is correct
61 Correct 273 ms 31308 KB Output is correct
62 Correct 279 ms 31152 KB Output is correct
63 Correct 306 ms 31160 KB Output is correct
64 Correct 261 ms 31140 KB Output is correct
65 Correct 288 ms 31200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8020 KB Output is correct
2 Correct 4 ms 8020 KB Output is correct
3 Correct 3 ms 8020 KB Output is correct
4 Correct 4 ms 8148 KB Output is correct
5 Correct 4 ms 8020 KB Output is correct
6 Correct 4 ms 8020 KB Output is correct
7 Correct 4 ms 8020 KB Output is correct
8 Correct 4 ms 8148 KB Output is correct
9 Correct 4 ms 8020 KB Output is correct
10 Correct 6 ms 8020 KB Output is correct
11 Correct 4 ms 8148 KB Output is correct
12 Correct 4 ms 8020 KB Output is correct
13 Correct 4 ms 8048 KB Output is correct
14 Correct 4 ms 8020 KB Output is correct
15 Correct 4 ms 8020 KB Output is correct
16 Correct 4 ms 8196 KB Output is correct
17 Correct 4 ms 8036 KB Output is correct
18 Correct 4 ms 8020 KB Output is correct
19 Correct 5 ms 8020 KB Output is correct
20 Correct 4 ms 8020 KB Output is correct
21 Correct 4 ms 8020 KB Output is correct
22 Correct 5 ms 8020 KB Output is correct
23 Correct 4 ms 8028 KB Output is correct
24 Correct 4 ms 8020 KB Output is correct
25 Correct 4 ms 8020 KB Output is correct
26 Correct 268 ms 31564 KB Output is correct
27 Correct 256 ms 32180 KB Output is correct
28 Correct 256 ms 32060 KB Output is correct
29 Correct 256 ms 32148 KB Output is correct
30 Correct 269 ms 32056 KB Output is correct
31 Correct 233 ms 32100 KB Output is correct
32 Correct 231 ms 32044 KB Output is correct
33 Correct 229 ms 32056 KB Output is correct
34 Correct 224 ms 32140 KB Output is correct
35 Correct 231 ms 32052 KB Output is correct
36 Correct 271 ms 32072 KB Output is correct
37 Correct 258 ms 32076 KB Output is correct
38 Correct 259 ms 32104 KB Output is correct
39 Correct 225 ms 32184 KB Output is correct
40 Correct 230 ms 32140 KB Output is correct
41 Correct 243 ms 32060 KB Output is correct
42 Correct 230 ms 32084 KB Output is correct
43 Correct 304 ms 32176 KB Output is correct
44 Correct 252 ms 32140 KB Output is correct
45 Correct 263 ms 32188 KB Output is correct
46 Correct 3 ms 8020 KB Output is correct
47 Correct 220 ms 31160 KB Output is correct
48 Correct 223 ms 31132 KB Output is correct
49 Correct 231 ms 31156 KB Output is correct
50 Correct 219 ms 31124 KB Output is correct
51 Correct 212 ms 31176 KB Output is correct
52 Correct 230 ms 31276 KB Output is correct
53 Correct 218 ms 31208 KB Output is correct
54 Correct 216 ms 31160 KB Output is correct
55 Correct 225 ms 31192 KB Output is correct
56 Correct 214 ms 31252 KB Output is correct
57 Correct 217 ms 31100 KB Output is correct
58 Correct 219 ms 31128 KB Output is correct
59 Correct 221 ms 31188 KB Output is correct
60 Correct 243 ms 31084 KB Output is correct
61 Correct 222 ms 31200 KB Output is correct
62 Correct 216 ms 31164 KB Output is correct
63 Correct 217 ms 31200 KB Output is correct
64 Correct 223 ms 31256 KB Output is correct
65 Correct 224 ms 31156 KB Output is correct
66 Correct 238 ms 31088 KB Output is correct
67 Correct 5 ms 8140 KB Output is correct
68 Correct 6 ms 8336 KB Output is correct
69 Correct 5 ms 8284 KB Output is correct
70 Correct 5 ms 8276 KB Output is correct
71 Correct 4 ms 8276 KB Output is correct
72 Correct 5 ms 8276 KB Output is correct
73 Correct 5 ms 8284 KB Output is correct
74 Correct 5 ms 8284 KB Output is correct
75 Correct 6 ms 8276 KB Output is correct
76 Correct 5 ms 8288 KB Output is correct
77 Correct 5 ms 8276 KB Output is correct
78 Correct 6 ms 8280 KB Output is correct
79 Correct 7 ms 8276 KB Output is correct
80 Correct 6 ms 8276 KB Output is correct
81 Correct 4 ms 8148 KB Output is correct
82 Correct 5 ms 8276 KB Output is correct
83 Correct 5 ms 8276 KB Output is correct
84 Correct 5 ms 8276 KB Output is correct
85 Correct 5 ms 8276 KB Output is correct
86 Correct 4 ms 8276 KB Output is correct
87 Correct 4 ms 8276 KB Output is correct
88 Correct 6 ms 8280 KB Output is correct
89 Correct 4 ms 8020 KB Output is correct
90 Correct 5 ms 8276 KB Output is correct
91 Correct 5 ms 8284 KB Output is correct
92 Correct 5 ms 8276 KB Output is correct
93 Correct 5 ms 8276 KB Output is correct
94 Correct 6 ms 8276 KB Output is correct
95 Correct 5 ms 8276 KB Output is correct
96 Correct 6 ms 8276 KB Output is correct
97 Correct 5 ms 8308 KB Output is correct
98 Correct 5 ms 8276 KB Output is correct
99 Correct 5 ms 8276 KB Output is correct
100 Correct 5 ms 8280 KB Output is correct
101 Correct 5 ms 8276 KB Output is correct
102 Correct 5 ms 8276 KB Output is correct
103 Correct 4 ms 8140 KB Output is correct
104 Correct 5 ms 8304 KB Output is correct
105 Correct 5 ms 8276 KB Output is correct
106 Correct 5 ms 8276 KB Output is correct
107 Correct 5 ms 8284 KB Output is correct
108 Correct 5 ms 8272 KB Output is correct
109 Correct 5 ms 8276 KB Output is correct
110 Correct 5 ms 8276 KB Output is correct
111 Correct 5 ms 8020 KB Output is correct
112 Correct 257 ms 31156 KB Output is correct
113 Correct 259 ms 31192 KB Output is correct
114 Correct 291 ms 31200 KB Output is correct
115 Correct 262 ms 31112 KB Output is correct
116 Correct 258 ms 31204 KB Output is correct
117 Correct 261 ms 31084 KB Output is correct
118 Correct 263 ms 31264 KB Output is correct
119 Correct 279 ms 31100 KB Output is correct
120 Correct 262 ms 31252 KB Output is correct
121 Correct 297 ms 31152 KB Output is correct
122 Correct 258 ms 31368 KB Output is correct
123 Correct 291 ms 31180 KB Output is correct
124 Correct 263 ms 31156 KB Output is correct
125 Correct 4 ms 8020 KB Output is correct
126 Correct 319 ms 31132 KB Output is correct
127 Correct 271 ms 31132 KB Output is correct
128 Correct 273 ms 31308 KB Output is correct
129 Correct 279 ms 31152 KB Output is correct
130 Correct 306 ms 31160 KB Output is correct
131 Correct 261 ms 31140 KB Output is correct
132 Correct 288 ms 31200 KB Output is correct
133 Correct 4 ms 8020 KB Output is correct
134 Correct 273 ms 32156 KB Output is correct
135 Correct 311 ms 32044 KB Output is correct
136 Correct 261 ms 32260 KB Output is correct
137 Correct 295 ms 32160 KB Output is correct
138 Correct 257 ms 32076 KB Output is correct
139 Correct 256 ms 32340 KB Output is correct
140 Correct 278 ms 32132 KB Output is correct
141 Correct 266 ms 32156 KB Output is correct
142 Correct 272 ms 32076 KB Output is correct
143 Correct 258 ms 32048 KB Output is correct
144 Correct 299 ms 32200 KB Output is correct
145 Correct 318 ms 32040 KB Output is correct
146 Correct 257 ms 32204 KB Output is correct
147 Correct 3 ms 8020 KB Output is correct
148 Correct 272 ms 32172 KB Output is correct
149 Correct 258 ms 32136 KB Output is correct
150 Correct 251 ms 32160 KB Output is correct
151 Correct 280 ms 32048 KB Output is correct
152 Correct 256 ms 32156 KB Output is correct
153 Correct 269 ms 32212 KB Output is correct
154 Correct 251 ms 32056 KB Output is correct