Submission #948347

# Submission time Handle Problem Language Result Execution time Memory
948347 2024-03-18T04:38:26 Z Lilypad Cryptography (NOI20_crypto) C++14
48 / 100
1000 ms 7312 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define pb push_back
#define fi first
#define se second

const ll N = 3e5+3;
const ll MOD = 1e9+7;

ll a[N],b[N],fac[N];
ll n,tmp,ans;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	fac[0] = 1;
	for(int i=1; i<=n; i++) {
		cin >> a[i];
		b[i] = a[i];
		fac[i] = fac[i-1] * i;
		fac[i] %= MOD;
	}
//	sort(b+1,b+n+1);
//	for(int i=1; i<=n; i++) {
//		mp[b[i]] = i;
//	}
//	for(int i=1; i<=n; i++) a[i] = mp[a[i]];
	for(int i=1; i<=n; i++) {
		tmp = 0;
		for(int j=i+1; j<=n; j++) {
			if(a[i] > a[j]) tmp++;
		}
		ans += (fac[n-i] * tmp) % MOD;
		ans %= MOD;
	}
	cout << (ans + 1) % MOD << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4556 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Execution timed out 1095 ms 7260 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Execution timed out 1074 ms 7312 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 4 ms 4444 KB Output is correct
3 Correct 4 ms 4444 KB Output is correct
4 Correct 4 ms 4444 KB Output is correct
5 Correct 4 ms 4444 KB Output is correct
6 Correct 4 ms 4444 KB Output is correct
7 Correct 4 ms 4444 KB Output is correct
8 Correct 4 ms 4444 KB Output is correct
9 Correct 4 ms 4440 KB Output is correct
10 Correct 5 ms 4440 KB Output is correct
11 Correct 4 ms 4592 KB Output is correct
12 Correct 4 ms 4444 KB Output is correct
13 Correct 4 ms 4444 KB Output is correct
14 Correct 5 ms 4592 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 5 ms 4572 KB Output is correct
17 Correct 5 ms 4444 KB Output is correct
18 Correct 4 ms 4444 KB Output is correct
19 Correct 4 ms 4444 KB Output is correct
20 Correct 6 ms 4604 KB Output is correct
21 Correct 4 ms 4444 KB Output is correct
22 Correct 4 ms 4608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4556 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 4 ms 4444 KB Output is correct
27 Correct 4 ms 4444 KB Output is correct
28 Correct 4 ms 4444 KB Output is correct
29 Correct 4 ms 4444 KB Output is correct
30 Correct 4 ms 4444 KB Output is correct
31 Correct 4 ms 4444 KB Output is correct
32 Correct 4 ms 4444 KB Output is correct
33 Correct 4 ms 4440 KB Output is correct
34 Correct 5 ms 4440 KB Output is correct
35 Correct 4 ms 4592 KB Output is correct
36 Correct 4 ms 4444 KB Output is correct
37 Correct 4 ms 4444 KB Output is correct
38 Correct 5 ms 4592 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 5 ms 4572 KB Output is correct
41 Correct 5 ms 4444 KB Output is correct
42 Correct 4 ms 4444 KB Output is correct
43 Correct 4 ms 4444 KB Output is correct
44 Correct 6 ms 4604 KB Output is correct
45 Correct 4 ms 4444 KB Output is correct
46 Correct 4 ms 4608 KB Output is correct
47 Correct 1 ms 4444 KB Output is correct
48 Correct 4 ms 4444 KB Output is correct
49 Correct 4 ms 4624 KB Output is correct
50 Correct 4 ms 4444 KB Output is correct
51 Correct 4 ms 4444 KB Output is correct
52 Correct 4 ms 4612 KB Output is correct
53 Correct 4 ms 4444 KB Output is correct
54 Correct 4 ms 4444 KB Output is correct
55 Correct 5 ms 4612 KB Output is correct
56 Correct 4 ms 4444 KB Output is correct
57 Correct 4 ms 4444 KB Output is correct
58 Correct 5 ms 4444 KB Output is correct
59 Correct 4 ms 4444 KB Output is correct
60 Correct 5 ms 4444 KB Output is correct
61 Correct 1 ms 4444 KB Output is correct
62 Correct 4 ms 4628 KB Output is correct
63 Correct 4 ms 4444 KB Output is correct
64 Correct 4 ms 4444 KB Output is correct
65 Correct 5 ms 4444 KB Output is correct
66 Correct 4 ms 4608 KB Output is correct
67 Correct 4 ms 4568 KB Output is correct
68 Correct 4 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Execution timed out 1074 ms 7312 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4556 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Execution timed out 1095 ms 7260 KB Time limit exceeded
27 Halted 0 ms 0 KB -