Submission #951204

# Submission time Handle Problem Language Result Execution time Memory
951204 2024-03-21T11:06:58 Z NourWael Cryptography (NOI20_crypto) C++17
100 / 100
422 ms 27032 KB
#include <bits/extc++.h>
#define int long long
using namespace std; 
using namespace __gnu_pbds; 
int const mxN = 3e5+5;
int const mod = 1e9+7;
int perm[mxN], a[mxN];

signed main() {
  
  ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

  int n; cin>>n;
  perm[1] = 1;
  for(int i=2; i<=n; i++) perm[i] = (perm[i-1] * i) % mod;
  
  tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> st;
  for(int i=0; i<n; i++) { cin>>a[i]; st.insert(a[i]); }
  
  int ans = 0;
  for(int i=0; i<n; i++) {
     int t = st.order_of_key(a[i]);
     ans += (t*perm[n-i-1])%mod;
     ans%=mod;
     st.erase(a[i]);
  }

  cout<<(ans+1)%mod;
   return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2424 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2512 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 271 ms 26708 KB Output is correct
3 Correct 279 ms 26820 KB Output is correct
4 Correct 274 ms 26952 KB Output is correct
5 Correct 273 ms 26708 KB Output is correct
6 Correct 269 ms 26708 KB Output is correct
7 Correct 284 ms 26824 KB Output is correct
8 Correct 284 ms 27032 KB Output is correct
9 Correct 284 ms 26712 KB Output is correct
10 Correct 285 ms 26712 KB Output is correct
11 Correct 283 ms 26660 KB Output is correct
12 Correct 275 ms 26888 KB Output is correct
13 Correct 274 ms 26828 KB Output is correct
14 Correct 277 ms 26708 KB Output is correct
15 Correct 282 ms 26832 KB Output is correct
16 Correct 283 ms 26824 KB Output is correct
17 Correct 277 ms 26820 KB Output is correct
18 Correct 283 ms 26724 KB Output is correct
19 Correct 275 ms 26708 KB Output is correct
20 Correct 274 ms 26820 KB Output is correct
21 Correct 276 ms 26720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 270 ms 25876 KB Output is correct
3 Correct 274 ms 25680 KB Output is correct
4 Correct 263 ms 25860 KB Output is correct
5 Correct 260 ms 25804 KB Output is correct
6 Correct 263 ms 25724 KB Output is correct
7 Correct 289 ms 25984 KB Output is correct
8 Correct 272 ms 25824 KB Output is correct
9 Correct 271 ms 25752 KB Output is correct
10 Correct 265 ms 25728 KB Output is correct
11 Correct 263 ms 25872 KB Output is correct
12 Correct 284 ms 25776 KB Output is correct
13 Correct 262 ms 25880 KB Output is correct
14 Correct 266 ms 25680 KB Output is correct
15 Correct 267 ms 25864 KB Output is correct
16 Correct 256 ms 25812 KB Output is correct
17 Correct 261 ms 25868 KB Output is correct
18 Correct 261 ms 25652 KB Output is correct
19 Correct 276 ms 25684 KB Output is correct
20 Correct 276 ms 25680 KB Output is correct
21 Correct 264 ms 25652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 3 ms 2520 KB Output is correct
5 Correct 2 ms 2652 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 2 ms 2652 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
9 Correct 2 ms 2652 KB Output is correct
10 Correct 3 ms 2648 KB Output is correct
11 Correct 2 ms 2648 KB Output is correct
12 Correct 2 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 2 ms 2652 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 2 ms 2652 KB Output is correct
22 Correct 2 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2424 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2512 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 2 ms 2652 KB Output is correct
27 Correct 2 ms 2652 KB Output is correct
28 Correct 3 ms 2520 KB Output is correct
29 Correct 2 ms 2652 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
32 Correct 2 ms 2652 KB Output is correct
33 Correct 2 ms 2652 KB Output is correct
34 Correct 3 ms 2648 KB Output is correct
35 Correct 2 ms 2648 KB Output is correct
36 Correct 2 ms 2652 KB Output is correct
37 Correct 2 ms 2652 KB Output is correct
38 Correct 2 ms 2652 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 2 ms 2652 KB Output is correct
41 Correct 2 ms 2652 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 2 ms 2652 KB Output is correct
44 Correct 2 ms 2652 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 2 ms 2652 KB Output is correct
47 Correct 1 ms 2392 KB Output is correct
48 Correct 3 ms 2652 KB Output is correct
49 Correct 2 ms 2652 KB Output is correct
50 Correct 2 ms 2652 KB Output is correct
51 Correct 3 ms 2652 KB Output is correct
52 Correct 2 ms 2652 KB Output is correct
53 Correct 3 ms 2652 KB Output is correct
54 Correct 2 ms 2664 KB Output is correct
55 Correct 2 ms 2524 KB Output is correct
56 Correct 2 ms 2648 KB Output is correct
57 Correct 2 ms 2652 KB Output is correct
58 Correct 2 ms 2652 KB Output is correct
59 Correct 2 ms 2652 KB Output is correct
60 Correct 2 ms 2652 KB Output is correct
61 Correct 1 ms 2396 KB Output is correct
62 Correct 2 ms 2780 KB Output is correct
63 Correct 2 ms 2652 KB Output is correct
64 Correct 2 ms 2652 KB Output is correct
65 Correct 2 ms 2648 KB Output is correct
66 Correct 2 ms 2648 KB Output is correct
67 Correct 3 ms 2520 KB Output is correct
68 Correct 2 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 270 ms 25876 KB Output is correct
3 Correct 274 ms 25680 KB Output is correct
4 Correct 263 ms 25860 KB Output is correct
5 Correct 260 ms 25804 KB Output is correct
6 Correct 263 ms 25724 KB Output is correct
7 Correct 289 ms 25984 KB Output is correct
8 Correct 272 ms 25824 KB Output is correct
9 Correct 271 ms 25752 KB Output is correct
10 Correct 265 ms 25728 KB Output is correct
11 Correct 263 ms 25872 KB Output is correct
12 Correct 284 ms 25776 KB Output is correct
13 Correct 262 ms 25880 KB Output is correct
14 Correct 266 ms 25680 KB Output is correct
15 Correct 267 ms 25864 KB Output is correct
16 Correct 256 ms 25812 KB Output is correct
17 Correct 261 ms 25868 KB Output is correct
18 Correct 261 ms 25652 KB Output is correct
19 Correct 276 ms 25684 KB Output is correct
20 Correct 276 ms 25680 KB Output is correct
21 Correct 264 ms 25652 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 2 ms 2652 KB Output is correct
24 Correct 2 ms 2652 KB Output is correct
25 Correct 3 ms 2520 KB Output is correct
26 Correct 2 ms 2652 KB Output is correct
27 Correct 2 ms 2652 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 2 ms 2652 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 3 ms 2648 KB Output is correct
32 Correct 2 ms 2648 KB Output is correct
33 Correct 2 ms 2652 KB Output is correct
34 Correct 2 ms 2652 KB Output is correct
35 Correct 2 ms 2652 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 2 ms 2652 KB Output is correct
38 Correct 2 ms 2652 KB Output is correct
39 Correct 2 ms 2652 KB Output is correct
40 Correct 2 ms 2652 KB Output is correct
41 Correct 2 ms 2652 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 2 ms 2652 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 402 ms 25928 KB Output is correct
46 Correct 290 ms 25864 KB Output is correct
47 Correct 275 ms 25684 KB Output is correct
48 Correct 285 ms 25644 KB Output is correct
49 Correct 285 ms 25684 KB Output is correct
50 Correct 290 ms 25868 KB Output is correct
51 Correct 279 ms 25860 KB Output is correct
52 Correct 277 ms 25936 KB Output is correct
53 Correct 314 ms 25868 KB Output is correct
54 Correct 302 ms 25688 KB Output is correct
55 Correct 349 ms 25860 KB Output is correct
56 Correct 341 ms 25732 KB Output is correct
57 Correct 296 ms 25768 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 365 ms 25760 KB Output is correct
60 Correct 312 ms 25864 KB Output is correct
61 Correct 357 ms 25832 KB Output is correct
62 Correct 297 ms 25684 KB Output is correct
63 Correct 350 ms 25680 KB Output is correct
64 Correct 330 ms 25868 KB Output is correct
65 Correct 275 ms 25868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2424 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2512 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 271 ms 26708 KB Output is correct
27 Correct 279 ms 26820 KB Output is correct
28 Correct 274 ms 26952 KB Output is correct
29 Correct 273 ms 26708 KB Output is correct
30 Correct 269 ms 26708 KB Output is correct
31 Correct 284 ms 26824 KB Output is correct
32 Correct 284 ms 27032 KB Output is correct
33 Correct 284 ms 26712 KB Output is correct
34 Correct 285 ms 26712 KB Output is correct
35 Correct 283 ms 26660 KB Output is correct
36 Correct 275 ms 26888 KB Output is correct
37 Correct 274 ms 26828 KB Output is correct
38 Correct 277 ms 26708 KB Output is correct
39 Correct 282 ms 26832 KB Output is correct
40 Correct 283 ms 26824 KB Output is correct
41 Correct 277 ms 26820 KB Output is correct
42 Correct 283 ms 26724 KB Output is correct
43 Correct 275 ms 26708 KB Output is correct
44 Correct 274 ms 26820 KB Output is correct
45 Correct 276 ms 26720 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 270 ms 25876 KB Output is correct
48 Correct 274 ms 25680 KB Output is correct
49 Correct 263 ms 25860 KB Output is correct
50 Correct 260 ms 25804 KB Output is correct
51 Correct 263 ms 25724 KB Output is correct
52 Correct 289 ms 25984 KB Output is correct
53 Correct 272 ms 25824 KB Output is correct
54 Correct 271 ms 25752 KB Output is correct
55 Correct 265 ms 25728 KB Output is correct
56 Correct 263 ms 25872 KB Output is correct
57 Correct 284 ms 25776 KB Output is correct
58 Correct 262 ms 25880 KB Output is correct
59 Correct 266 ms 25680 KB Output is correct
60 Correct 267 ms 25864 KB Output is correct
61 Correct 256 ms 25812 KB Output is correct
62 Correct 261 ms 25868 KB Output is correct
63 Correct 261 ms 25652 KB Output is correct
64 Correct 276 ms 25684 KB Output is correct
65 Correct 276 ms 25680 KB Output is correct
66 Correct 264 ms 25652 KB Output is correct
67 Correct 1 ms 2392 KB Output is correct
68 Correct 2 ms 2652 KB Output is correct
69 Correct 2 ms 2652 KB Output is correct
70 Correct 3 ms 2520 KB Output is correct
71 Correct 2 ms 2652 KB Output is correct
72 Correct 2 ms 2652 KB Output is correct
73 Correct 2 ms 2652 KB Output is correct
74 Correct 2 ms 2652 KB Output is correct
75 Correct 2 ms 2652 KB Output is correct
76 Correct 3 ms 2648 KB Output is correct
77 Correct 2 ms 2648 KB Output is correct
78 Correct 2 ms 2652 KB Output is correct
79 Correct 2 ms 2652 KB Output is correct
80 Correct 2 ms 2652 KB Output is correct
81 Correct 1 ms 2396 KB Output is correct
82 Correct 2 ms 2652 KB Output is correct
83 Correct 2 ms 2652 KB Output is correct
84 Correct 2 ms 2652 KB Output is correct
85 Correct 2 ms 2652 KB Output is correct
86 Correct 2 ms 2652 KB Output is correct
87 Correct 2 ms 2652 KB Output is correct
88 Correct 2 ms 2652 KB Output is correct
89 Correct 1 ms 2392 KB Output is correct
90 Correct 3 ms 2652 KB Output is correct
91 Correct 2 ms 2652 KB Output is correct
92 Correct 2 ms 2652 KB Output is correct
93 Correct 3 ms 2652 KB Output is correct
94 Correct 2 ms 2652 KB Output is correct
95 Correct 3 ms 2652 KB Output is correct
96 Correct 2 ms 2664 KB Output is correct
97 Correct 2 ms 2524 KB Output is correct
98 Correct 2 ms 2648 KB Output is correct
99 Correct 2 ms 2652 KB Output is correct
100 Correct 2 ms 2652 KB Output is correct
101 Correct 2 ms 2652 KB Output is correct
102 Correct 2 ms 2652 KB Output is correct
103 Correct 1 ms 2396 KB Output is correct
104 Correct 2 ms 2780 KB Output is correct
105 Correct 2 ms 2652 KB Output is correct
106 Correct 2 ms 2652 KB Output is correct
107 Correct 2 ms 2648 KB Output is correct
108 Correct 2 ms 2648 KB Output is correct
109 Correct 3 ms 2520 KB Output is correct
110 Correct 2 ms 2652 KB Output is correct
111 Correct 1 ms 2396 KB Output is correct
112 Correct 402 ms 25928 KB Output is correct
113 Correct 290 ms 25864 KB Output is correct
114 Correct 275 ms 25684 KB Output is correct
115 Correct 285 ms 25644 KB Output is correct
116 Correct 285 ms 25684 KB Output is correct
117 Correct 290 ms 25868 KB Output is correct
118 Correct 279 ms 25860 KB Output is correct
119 Correct 277 ms 25936 KB Output is correct
120 Correct 314 ms 25868 KB Output is correct
121 Correct 302 ms 25688 KB Output is correct
122 Correct 349 ms 25860 KB Output is correct
123 Correct 341 ms 25732 KB Output is correct
124 Correct 296 ms 25768 KB Output is correct
125 Correct 1 ms 2396 KB Output is correct
126 Correct 365 ms 25760 KB Output is correct
127 Correct 312 ms 25864 KB Output is correct
128 Correct 357 ms 25832 KB Output is correct
129 Correct 297 ms 25684 KB Output is correct
130 Correct 350 ms 25680 KB Output is correct
131 Correct 330 ms 25868 KB Output is correct
132 Correct 275 ms 25868 KB Output is correct
133 Correct 1 ms 2396 KB Output is correct
134 Correct 283 ms 26964 KB Output is correct
135 Correct 290 ms 26824 KB Output is correct
136 Correct 350 ms 26760 KB Output is correct
137 Correct 312 ms 26588 KB Output is correct
138 Correct 310 ms 26684 KB Output is correct
139 Correct 371 ms 26708 KB Output is correct
140 Correct 373 ms 26824 KB Output is correct
141 Correct 319 ms 26644 KB Output is correct
142 Correct 422 ms 26824 KB Output is correct
143 Correct 297 ms 26672 KB Output is correct
144 Correct 375 ms 26832 KB Output is correct
145 Correct 319 ms 26996 KB Output is correct
146 Correct 372 ms 26668 KB Output is correct
147 Correct 1 ms 2396 KB Output is correct
148 Correct 373 ms 26768 KB Output is correct
149 Correct 278 ms 26708 KB Output is correct
150 Correct 319 ms 26960 KB Output is correct
151 Correct 282 ms 26824 KB Output is correct
152 Correct 286 ms 26748 KB Output is correct
153 Correct 287 ms 26704 KB Output is correct
154 Correct 274 ms 26592 KB Output is correct