답안 #739899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
739899 2023-05-11T14:27:11 Z MODDI Cryptography (NOI20_crypto) C++14
100 / 100
855 ms 43220 KB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n;
vl arr, p;
const int mod = 1e9 + 7;
ll power[300100];
int main(){
	cin>>n;
	arr.resize(n);
	for(int i = 0; i < n; i++){
		cin>>arr[i];
		p.pb(arr[i]);
	}
	memset(power, 0, sizeof power);
	power[1] = 1;
	for(int i =2; i < n; i++){
		power[i] = i * power[i-1];
		power[i] %= mod;
	}
	sort(p.begin(), p.end());
	map<ll, ll> lower;
	for(int i = 0; i < n; i++)
		lower[p[i]] = i;
		
	int ele = n - 1;
	ll ans = 0;
	ordered_set o_set;
	for(int i = 0; i < n; i++){
		ll here = lower[arr[i]] - o_set.order_of_key(arr[i]);
//		cout<<here<<" "; 
//		cout<<here<<" "<<power[ele]<<" "<<ele<<endl;
		ans += (here * power[ele]) % mod;
		ans %= mod;
		ele--;
		o_set.insert(arr[i]);
	}
//	cout<<endl;
	cout<<(ans+1)%mod<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2644 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 1 ms 2644 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 1 ms 2644 KB Output is correct
22 Correct 1 ms 2644 KB Output is correct
23 Correct 1 ms 2644 KB Output is correct
24 Correct 1 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 387 ms 40240 KB Output is correct
3 Correct 381 ms 43172 KB Output is correct
4 Correct 386 ms 43188 KB Output is correct
5 Correct 387 ms 43144 KB Output is correct
6 Correct 380 ms 43072 KB Output is correct
7 Correct 409 ms 43132 KB Output is correct
8 Correct 410 ms 43064 KB Output is correct
9 Correct 403 ms 43220 KB Output is correct
10 Correct 403 ms 43052 KB Output is correct
11 Correct 406 ms 43164 KB Output is correct
12 Correct 390 ms 43068 KB Output is correct
13 Correct 394 ms 43036 KB Output is correct
14 Correct 409 ms 43088 KB Output is correct
15 Correct 423 ms 43064 KB Output is correct
16 Correct 412 ms 43200 KB Output is correct
17 Correct 420 ms 43032 KB Output is correct
18 Correct 424 ms 43124 KB Output is correct
19 Correct 403 ms 43136 KB Output is correct
20 Correct 425 ms 43028 KB Output is correct
21 Correct 410 ms 43080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 394 ms 40260 KB Output is correct
3 Correct 427 ms 42128 KB Output is correct
4 Correct 397 ms 42180 KB Output is correct
5 Correct 404 ms 42092 KB Output is correct
6 Correct 417 ms 42108 KB Output is correct
7 Correct 439 ms 42136 KB Output is correct
8 Correct 384 ms 42136 KB Output is correct
9 Correct 430 ms 42084 KB Output is correct
10 Correct 402 ms 42176 KB Output is correct
11 Correct 423 ms 42236 KB Output is correct
12 Correct 440 ms 42056 KB Output is correct
13 Correct 414 ms 42280 KB Output is correct
14 Correct 423 ms 42228 KB Output is correct
15 Correct 400 ms 42096 KB Output is correct
16 Correct 417 ms 42156 KB Output is correct
17 Correct 411 ms 42248 KB Output is correct
18 Correct 424 ms 42164 KB Output is correct
19 Correct 440 ms 42152 KB Output is correct
20 Correct 448 ms 42156 KB Output is correct
21 Correct 416 ms 42096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 4 ms 3028 KB Output is correct
3 Correct 4 ms 3008 KB Output is correct
4 Correct 4 ms 3028 KB Output is correct
5 Correct 4 ms 3004 KB Output is correct
6 Correct 4 ms 3028 KB Output is correct
7 Correct 5 ms 3040 KB Output is correct
8 Correct 4 ms 3008 KB Output is correct
9 Correct 4 ms 3012 KB Output is correct
10 Correct 4 ms 3028 KB Output is correct
11 Correct 4 ms 3028 KB Output is correct
12 Correct 4 ms 3028 KB Output is correct
13 Correct 4 ms 3028 KB Output is correct
14 Correct 4 ms 3028 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 4 ms 3028 KB Output is correct
17 Correct 4 ms 3028 KB Output is correct
18 Correct 4 ms 3028 KB Output is correct
19 Correct 4 ms 3028 KB Output is correct
20 Correct 5 ms 3004 KB Output is correct
21 Correct 4 ms 3028 KB Output is correct
22 Correct 3 ms 3028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2644 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 1 ms 2644 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 1 ms 2644 KB Output is correct
22 Correct 1 ms 2644 KB Output is correct
23 Correct 1 ms 2644 KB Output is correct
24 Correct 1 ms 2644 KB Output is correct
25 Correct 1 ms 2644 KB Output is correct
26 Correct 4 ms 3028 KB Output is correct
27 Correct 4 ms 3008 KB Output is correct
28 Correct 4 ms 3028 KB Output is correct
29 Correct 4 ms 3004 KB Output is correct
30 Correct 4 ms 3028 KB Output is correct
31 Correct 5 ms 3040 KB Output is correct
32 Correct 4 ms 3008 KB Output is correct
33 Correct 4 ms 3012 KB Output is correct
34 Correct 4 ms 3028 KB Output is correct
35 Correct 4 ms 3028 KB Output is correct
36 Correct 4 ms 3028 KB Output is correct
37 Correct 4 ms 3028 KB Output is correct
38 Correct 4 ms 3028 KB Output is correct
39 Correct 1 ms 2644 KB Output is correct
40 Correct 4 ms 3028 KB Output is correct
41 Correct 4 ms 3028 KB Output is correct
42 Correct 4 ms 3028 KB Output is correct
43 Correct 4 ms 3028 KB Output is correct
44 Correct 5 ms 3004 KB Output is correct
45 Correct 4 ms 3028 KB Output is correct
46 Correct 3 ms 3028 KB Output is correct
47 Correct 1 ms 2644 KB Output is correct
48 Correct 4 ms 3028 KB Output is correct
49 Correct 4 ms 3028 KB Output is correct
50 Correct 4 ms 3028 KB Output is correct
51 Correct 4 ms 3028 KB Output is correct
52 Correct 4 ms 3028 KB Output is correct
53 Correct 4 ms 3008 KB Output is correct
54 Correct 4 ms 3028 KB Output is correct
55 Correct 4 ms 3028 KB Output is correct
56 Correct 4 ms 3028 KB Output is correct
57 Correct 4 ms 3028 KB Output is correct
58 Correct 4 ms 3004 KB Output is correct
59 Correct 4 ms 3028 KB Output is correct
60 Correct 4 ms 2960 KB Output is correct
61 Correct 2 ms 2644 KB Output is correct
62 Correct 5 ms 3044 KB Output is correct
63 Correct 5 ms 3028 KB Output is correct
64 Correct 4 ms 3004 KB Output is correct
65 Correct 4 ms 3028 KB Output is correct
66 Correct 5 ms 3156 KB Output is correct
67 Correct 4 ms 2948 KB Output is correct
68 Correct 4 ms 3012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 394 ms 40260 KB Output is correct
3 Correct 427 ms 42128 KB Output is correct
4 Correct 397 ms 42180 KB Output is correct
5 Correct 404 ms 42092 KB Output is correct
6 Correct 417 ms 42108 KB Output is correct
7 Correct 439 ms 42136 KB Output is correct
8 Correct 384 ms 42136 KB Output is correct
9 Correct 430 ms 42084 KB Output is correct
10 Correct 402 ms 42176 KB Output is correct
11 Correct 423 ms 42236 KB Output is correct
12 Correct 440 ms 42056 KB Output is correct
13 Correct 414 ms 42280 KB Output is correct
14 Correct 423 ms 42228 KB Output is correct
15 Correct 400 ms 42096 KB Output is correct
16 Correct 417 ms 42156 KB Output is correct
17 Correct 411 ms 42248 KB Output is correct
18 Correct 424 ms 42164 KB Output is correct
19 Correct 440 ms 42152 KB Output is correct
20 Correct 448 ms 42156 KB Output is correct
21 Correct 416 ms 42096 KB Output is correct
22 Correct 1 ms 2644 KB Output is correct
23 Correct 4 ms 3028 KB Output is correct
24 Correct 4 ms 3008 KB Output is correct
25 Correct 4 ms 3028 KB Output is correct
26 Correct 4 ms 3004 KB Output is correct
27 Correct 4 ms 3028 KB Output is correct
28 Correct 5 ms 3040 KB Output is correct
29 Correct 4 ms 3008 KB Output is correct
30 Correct 4 ms 3012 KB Output is correct
31 Correct 4 ms 3028 KB Output is correct
32 Correct 4 ms 3028 KB Output is correct
33 Correct 4 ms 3028 KB Output is correct
34 Correct 4 ms 3028 KB Output is correct
35 Correct 4 ms 3028 KB Output is correct
36 Correct 1 ms 2644 KB Output is correct
37 Correct 4 ms 3028 KB Output is correct
38 Correct 4 ms 3028 KB Output is correct
39 Correct 4 ms 3028 KB Output is correct
40 Correct 4 ms 3028 KB Output is correct
41 Correct 5 ms 3004 KB Output is correct
42 Correct 4 ms 3028 KB Output is correct
43 Correct 3 ms 3028 KB Output is correct
44 Correct 1 ms 2644 KB Output is correct
45 Correct 697 ms 42060 KB Output is correct
46 Correct 731 ms 42076 KB Output is correct
47 Correct 720 ms 42168 KB Output is correct
48 Correct 855 ms 42308 KB Output is correct
49 Correct 737 ms 42148 KB Output is correct
50 Correct 722 ms 42192 KB Output is correct
51 Correct 723 ms 42164 KB Output is correct
52 Correct 734 ms 42284 KB Output is correct
53 Correct 760 ms 42180 KB Output is correct
54 Correct 706 ms 42144 KB Output is correct
55 Correct 746 ms 42208 KB Output is correct
56 Correct 734 ms 42164 KB Output is correct
57 Correct 799 ms 42204 KB Output is correct
58 Correct 2 ms 2644 KB Output is correct
59 Correct 694 ms 42160 KB Output is correct
60 Correct 755 ms 42256 KB Output is correct
61 Correct 815 ms 42164 KB Output is correct
62 Correct 791 ms 42192 KB Output is correct
63 Correct 703 ms 42188 KB Output is correct
64 Correct 733 ms 42184 KB Output is correct
65 Correct 757 ms 42296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2644 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 1 ms 2644 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 1 ms 2644 KB Output is correct
22 Correct 1 ms 2644 KB Output is correct
23 Correct 1 ms 2644 KB Output is correct
24 Correct 1 ms 2644 KB Output is correct
25 Correct 1 ms 2644 KB Output is correct
26 Correct 387 ms 40240 KB Output is correct
27 Correct 381 ms 43172 KB Output is correct
28 Correct 386 ms 43188 KB Output is correct
29 Correct 387 ms 43144 KB Output is correct
30 Correct 380 ms 43072 KB Output is correct
31 Correct 409 ms 43132 KB Output is correct
32 Correct 410 ms 43064 KB Output is correct
33 Correct 403 ms 43220 KB Output is correct
34 Correct 403 ms 43052 KB Output is correct
35 Correct 406 ms 43164 KB Output is correct
36 Correct 390 ms 43068 KB Output is correct
37 Correct 394 ms 43036 KB Output is correct
38 Correct 409 ms 43088 KB Output is correct
39 Correct 423 ms 43064 KB Output is correct
40 Correct 412 ms 43200 KB Output is correct
41 Correct 420 ms 43032 KB Output is correct
42 Correct 424 ms 43124 KB Output is correct
43 Correct 403 ms 43136 KB Output is correct
44 Correct 425 ms 43028 KB Output is correct
45 Correct 410 ms 43080 KB Output is correct
46 Correct 1 ms 2644 KB Output is correct
47 Correct 394 ms 40260 KB Output is correct
48 Correct 427 ms 42128 KB Output is correct
49 Correct 397 ms 42180 KB Output is correct
50 Correct 404 ms 42092 KB Output is correct
51 Correct 417 ms 42108 KB Output is correct
52 Correct 439 ms 42136 KB Output is correct
53 Correct 384 ms 42136 KB Output is correct
54 Correct 430 ms 42084 KB Output is correct
55 Correct 402 ms 42176 KB Output is correct
56 Correct 423 ms 42236 KB Output is correct
57 Correct 440 ms 42056 KB Output is correct
58 Correct 414 ms 42280 KB Output is correct
59 Correct 423 ms 42228 KB Output is correct
60 Correct 400 ms 42096 KB Output is correct
61 Correct 417 ms 42156 KB Output is correct
62 Correct 411 ms 42248 KB Output is correct
63 Correct 424 ms 42164 KB Output is correct
64 Correct 440 ms 42152 KB Output is correct
65 Correct 448 ms 42156 KB Output is correct
66 Correct 416 ms 42096 KB Output is correct
67 Correct 1 ms 2644 KB Output is correct
68 Correct 4 ms 3028 KB Output is correct
69 Correct 4 ms 3008 KB Output is correct
70 Correct 4 ms 3028 KB Output is correct
71 Correct 4 ms 3004 KB Output is correct
72 Correct 4 ms 3028 KB Output is correct
73 Correct 5 ms 3040 KB Output is correct
74 Correct 4 ms 3008 KB Output is correct
75 Correct 4 ms 3012 KB Output is correct
76 Correct 4 ms 3028 KB Output is correct
77 Correct 4 ms 3028 KB Output is correct
78 Correct 4 ms 3028 KB Output is correct
79 Correct 4 ms 3028 KB Output is correct
80 Correct 4 ms 3028 KB Output is correct
81 Correct 1 ms 2644 KB Output is correct
82 Correct 4 ms 3028 KB Output is correct
83 Correct 4 ms 3028 KB Output is correct
84 Correct 4 ms 3028 KB Output is correct
85 Correct 4 ms 3028 KB Output is correct
86 Correct 5 ms 3004 KB Output is correct
87 Correct 4 ms 3028 KB Output is correct
88 Correct 3 ms 3028 KB Output is correct
89 Correct 1 ms 2644 KB Output is correct
90 Correct 4 ms 3028 KB Output is correct
91 Correct 4 ms 3028 KB Output is correct
92 Correct 4 ms 3028 KB Output is correct
93 Correct 4 ms 3028 KB Output is correct
94 Correct 4 ms 3028 KB Output is correct
95 Correct 4 ms 3008 KB Output is correct
96 Correct 4 ms 3028 KB Output is correct
97 Correct 4 ms 3028 KB Output is correct
98 Correct 4 ms 3028 KB Output is correct
99 Correct 4 ms 3028 KB Output is correct
100 Correct 4 ms 3004 KB Output is correct
101 Correct 4 ms 3028 KB Output is correct
102 Correct 4 ms 2960 KB Output is correct
103 Correct 2 ms 2644 KB Output is correct
104 Correct 5 ms 3044 KB Output is correct
105 Correct 5 ms 3028 KB Output is correct
106 Correct 4 ms 3004 KB Output is correct
107 Correct 4 ms 3028 KB Output is correct
108 Correct 5 ms 3156 KB Output is correct
109 Correct 4 ms 2948 KB Output is correct
110 Correct 4 ms 3012 KB Output is correct
111 Correct 1 ms 2644 KB Output is correct
112 Correct 697 ms 42060 KB Output is correct
113 Correct 731 ms 42076 KB Output is correct
114 Correct 720 ms 42168 KB Output is correct
115 Correct 855 ms 42308 KB Output is correct
116 Correct 737 ms 42148 KB Output is correct
117 Correct 722 ms 42192 KB Output is correct
118 Correct 723 ms 42164 KB Output is correct
119 Correct 734 ms 42284 KB Output is correct
120 Correct 760 ms 42180 KB Output is correct
121 Correct 706 ms 42144 KB Output is correct
122 Correct 746 ms 42208 KB Output is correct
123 Correct 734 ms 42164 KB Output is correct
124 Correct 799 ms 42204 KB Output is correct
125 Correct 2 ms 2644 KB Output is correct
126 Correct 694 ms 42160 KB Output is correct
127 Correct 755 ms 42256 KB Output is correct
128 Correct 815 ms 42164 KB Output is correct
129 Correct 791 ms 42192 KB Output is correct
130 Correct 703 ms 42188 KB Output is correct
131 Correct 733 ms 42184 KB Output is correct
132 Correct 757 ms 42296 KB Output is correct
133 Correct 2 ms 2644 KB Output is correct
134 Correct 778 ms 43116 KB Output is correct
135 Correct 765 ms 43112 KB Output is correct
136 Correct 738 ms 43012 KB Output is correct
137 Correct 760 ms 43016 KB Output is correct
138 Correct 767 ms 43148 KB Output is correct
139 Correct 757 ms 43140 KB Output is correct
140 Correct 696 ms 43088 KB Output is correct
141 Correct 780 ms 43204 KB Output is correct
142 Correct 709 ms 43152 KB Output is correct
143 Correct 733 ms 43080 KB Output is correct
144 Correct 735 ms 43052 KB Output is correct
145 Correct 713 ms 43172 KB Output is correct
146 Correct 713 ms 43100 KB Output is correct
147 Correct 2 ms 2644 KB Output is correct
148 Correct 709 ms 43204 KB Output is correct
149 Correct 709 ms 43068 KB Output is correct
150 Correct 802 ms 43108 KB Output is correct
151 Correct 792 ms 43056 KB Output is correct
152 Correct 756 ms 43124 KB Output is correct
153 Correct 818 ms 43080 KB Output is correct
154 Correct 783 ms 43012 KB Output is correct