Submission #958027

# Submission time Handle Problem Language Result Execution time Memory
958027 2024-04-04T17:16:32 Z Zena_Hossam Cryptography (NOI20_crypto) C++14
69 / 100
1000 ms 85732 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
using namespace std;
namespace __gnu_pbds
{
typedef tree<ll,
        null_type,
        less_equal<ll>,
        rb_tree_tag,
        tree_order_statistics_node_update> ordered_set;
}
using namespace __gnu_pbds;
#define fi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define ll double

#define ll1 long long
#define F first
#define S second
#define sz size()
#define all(s) s.begin(),s.end()
#define all1(s) s.rbegin(),s.rend()
ll mod=1e9+7;
int main()
{
    fi
    //freopen("stdin.in","r",stdin);freopen("stdout.out","w",stdout);
    //cin>>T;ll oo=0;
    ll n;
    cin>>n;
    map<ll,ll>m,d,dd;
    ll o=1;
    for(ll i=1;i<=n;i++){
        o=(i*o)%mod;
        m[i]=o;
    }
    ll arr[n],a[n];
    for(ll i=0;i<n;i++){

        cin>>a[i];
        arr[i]=a[i];
    }
    sort(a,a+n);
    for(ll i=0;i<n;i++){
        d[a[i]]=i+1;
    }
    for(ll i=1;i<=n;i++){
        dd[d[arr[i-1]]]=i;
    }
    ll k[n+5]={};ll c=0;
    ordered_set q;
    for(ll i=1;i<=n;i++){
        //cout<<i-q.order_of_key(dd[i])-1<<" ";
        c+=((m[(n-dd[i])]%mod)*((i-1-q.order_of_key(dd[i]))%mod))%mod;q.insert(dd[i]);
    }cout<<(c+1)%mod;
}

Compilation message

Crypto.cpp: In function 'int main()':
Crypto.cpp:51:8: warning: unused variable 'k' [-Wunused-variable]
   51 |     ll k[n+5]={};ll c=0;
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 643 ms 82600 KB Output is correct
3 Correct 581 ms 85528 KB Output is correct
4 Correct 586 ms 85412 KB Output is correct
5 Correct 585 ms 85584 KB Output is correct
6 Correct 585 ms 85332 KB Output is correct
7 Correct 638 ms 85456 KB Output is correct
8 Correct 591 ms 85460 KB Output is correct
9 Correct 591 ms 85584 KB Output is correct
10 Correct 631 ms 85468 KB Output is correct
11 Correct 706 ms 85412 KB Output is correct
12 Correct 581 ms 85444 KB Output is correct
13 Correct 581 ms 85732 KB Output is correct
14 Correct 645 ms 85360 KB Output is correct
15 Correct 610 ms 85448 KB Output is correct
16 Correct 641 ms 85448 KB Output is correct
17 Correct 616 ms 85516 KB Output is correct
18 Correct 618 ms 85576 KB Output is correct
19 Correct 597 ms 85456 KB Output is correct
20 Correct 592 ms 85380 KB Output is correct
21 Correct 581 ms 85512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 610 ms 82628 KB Output is correct
3 Correct 584 ms 84568 KB Output is correct
4 Correct 587 ms 84340 KB Output is correct
5 Correct 569 ms 84560 KB Output is correct
6 Correct 630 ms 84456 KB Output is correct
7 Correct 619 ms 84400 KB Output is correct
8 Correct 600 ms 84384 KB Output is correct
9 Correct 600 ms 84556 KB Output is correct
10 Correct 602 ms 84516 KB Output is correct
11 Correct 553 ms 84548 KB Output is correct
12 Correct 611 ms 84336 KB Output is correct
13 Correct 552 ms 84396 KB Output is correct
14 Correct 593 ms 84316 KB Output is correct
15 Correct 558 ms 84568 KB Output is correct
16 Correct 569 ms 84460 KB Output is correct
17 Correct 557 ms 84380 KB Output is correct
18 Correct 543 ms 84464 KB Output is correct
19 Correct 549 ms 84532 KB Output is correct
20 Correct 554 ms 84424 KB Output is correct
21 Correct 552 ms 84424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 3 ms 1208 KB Output is correct
3 Correct 4 ms 1112 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 3 ms 1116 KB Output is correct
6 Correct 4 ms 1116 KB Output is correct
7 Correct 3 ms 1116 KB Output is correct
8 Correct 3 ms 1112 KB Output is correct
9 Correct 5 ms 1116 KB Output is correct
10 Correct 4 ms 1116 KB Output is correct
11 Correct 5 ms 1116 KB Output is correct
12 Correct 3 ms 1116 KB Output is correct
13 Correct 4 ms 1116 KB Output is correct
14 Correct 4 ms 1112 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 4 ms 1116 KB Output is correct
17 Correct 4 ms 1288 KB Output is correct
18 Correct 3 ms 1368 KB Output is correct
19 Correct 4 ms 1116 KB Output is correct
20 Correct 3 ms 1112 KB Output is correct
21 Correct 4 ms 1116 KB Output is correct
22 Correct 4 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 3 ms 1208 KB Output is correct
27 Correct 4 ms 1112 KB Output is correct
28 Correct 3 ms 1116 KB Output is correct
29 Correct 3 ms 1116 KB Output is correct
30 Correct 4 ms 1116 KB Output is correct
31 Correct 3 ms 1116 KB Output is correct
32 Correct 3 ms 1112 KB Output is correct
33 Correct 5 ms 1116 KB Output is correct
34 Correct 4 ms 1116 KB Output is correct
35 Correct 5 ms 1116 KB Output is correct
36 Correct 3 ms 1116 KB Output is correct
37 Correct 4 ms 1116 KB Output is correct
38 Correct 4 ms 1112 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 4 ms 1116 KB Output is correct
41 Correct 4 ms 1288 KB Output is correct
42 Correct 3 ms 1368 KB Output is correct
43 Correct 4 ms 1116 KB Output is correct
44 Correct 3 ms 1112 KB Output is correct
45 Correct 4 ms 1116 KB Output is correct
46 Correct 4 ms 1116 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 4 ms 1116 KB Output is correct
49 Correct 5 ms 1372 KB Output is correct
50 Correct 4 ms 1116 KB Output is correct
51 Correct 4 ms 1176 KB Output is correct
52 Correct 4 ms 1112 KB Output is correct
53 Correct 4 ms 1116 KB Output is correct
54 Correct 3 ms 1112 KB Output is correct
55 Correct 4 ms 1116 KB Output is correct
56 Correct 4 ms 1308 KB Output is correct
57 Correct 4 ms 1384 KB Output is correct
58 Correct 4 ms 1112 KB Output is correct
59 Correct 4 ms 1116 KB Output is correct
60 Correct 4 ms 1148 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 5 ms 1188 KB Output is correct
63 Correct 4 ms 1116 KB Output is correct
64 Correct 3 ms 1116 KB Output is correct
65 Correct 4 ms 1116 KB Output is correct
66 Correct 4 ms 1116 KB Output is correct
67 Correct 4 ms 1116 KB Output is correct
68 Correct 4 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 610 ms 82628 KB Output is correct
3 Correct 584 ms 84568 KB Output is correct
4 Correct 587 ms 84340 KB Output is correct
5 Correct 569 ms 84560 KB Output is correct
6 Correct 630 ms 84456 KB Output is correct
7 Correct 619 ms 84400 KB Output is correct
8 Correct 600 ms 84384 KB Output is correct
9 Correct 600 ms 84556 KB Output is correct
10 Correct 602 ms 84516 KB Output is correct
11 Correct 553 ms 84548 KB Output is correct
12 Correct 611 ms 84336 KB Output is correct
13 Correct 552 ms 84396 KB Output is correct
14 Correct 593 ms 84316 KB Output is correct
15 Correct 558 ms 84568 KB Output is correct
16 Correct 569 ms 84460 KB Output is correct
17 Correct 557 ms 84380 KB Output is correct
18 Correct 543 ms 84464 KB Output is correct
19 Correct 549 ms 84532 KB Output is correct
20 Correct 554 ms 84424 KB Output is correct
21 Correct 552 ms 84424 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 3 ms 1208 KB Output is correct
24 Correct 4 ms 1112 KB Output is correct
25 Correct 3 ms 1116 KB Output is correct
26 Correct 3 ms 1116 KB Output is correct
27 Correct 4 ms 1116 KB Output is correct
28 Correct 3 ms 1116 KB Output is correct
29 Correct 3 ms 1112 KB Output is correct
30 Correct 5 ms 1116 KB Output is correct
31 Correct 4 ms 1116 KB Output is correct
32 Correct 5 ms 1116 KB Output is correct
33 Correct 3 ms 1116 KB Output is correct
34 Correct 4 ms 1116 KB Output is correct
35 Correct 4 ms 1112 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 4 ms 1116 KB Output is correct
38 Correct 4 ms 1288 KB Output is correct
39 Correct 3 ms 1368 KB Output is correct
40 Correct 4 ms 1116 KB Output is correct
41 Correct 3 ms 1112 KB Output is correct
42 Correct 4 ms 1116 KB Output is correct
43 Correct 4 ms 1116 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Execution timed out 1089 ms 82072 KB Time limit exceeded
46 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 643 ms 82600 KB Output is correct
27 Correct 581 ms 85528 KB Output is correct
28 Correct 586 ms 85412 KB Output is correct
29 Correct 585 ms 85584 KB Output is correct
30 Correct 585 ms 85332 KB Output is correct
31 Correct 638 ms 85456 KB Output is correct
32 Correct 591 ms 85460 KB Output is correct
33 Correct 591 ms 85584 KB Output is correct
34 Correct 631 ms 85468 KB Output is correct
35 Correct 706 ms 85412 KB Output is correct
36 Correct 581 ms 85444 KB Output is correct
37 Correct 581 ms 85732 KB Output is correct
38 Correct 645 ms 85360 KB Output is correct
39 Correct 610 ms 85448 KB Output is correct
40 Correct 641 ms 85448 KB Output is correct
41 Correct 616 ms 85516 KB Output is correct
42 Correct 618 ms 85576 KB Output is correct
43 Correct 597 ms 85456 KB Output is correct
44 Correct 592 ms 85380 KB Output is correct
45 Correct 581 ms 85512 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 610 ms 82628 KB Output is correct
48 Correct 584 ms 84568 KB Output is correct
49 Correct 587 ms 84340 KB Output is correct
50 Correct 569 ms 84560 KB Output is correct
51 Correct 630 ms 84456 KB Output is correct
52 Correct 619 ms 84400 KB Output is correct
53 Correct 600 ms 84384 KB Output is correct
54 Correct 600 ms 84556 KB Output is correct
55 Correct 602 ms 84516 KB Output is correct
56 Correct 553 ms 84548 KB Output is correct
57 Correct 611 ms 84336 KB Output is correct
58 Correct 552 ms 84396 KB Output is correct
59 Correct 593 ms 84316 KB Output is correct
60 Correct 558 ms 84568 KB Output is correct
61 Correct 569 ms 84460 KB Output is correct
62 Correct 557 ms 84380 KB Output is correct
63 Correct 543 ms 84464 KB Output is correct
64 Correct 549 ms 84532 KB Output is correct
65 Correct 554 ms 84424 KB Output is correct
66 Correct 552 ms 84424 KB Output is correct
67 Correct 0 ms 348 KB Output is correct
68 Correct 3 ms 1208 KB Output is correct
69 Correct 4 ms 1112 KB Output is correct
70 Correct 3 ms 1116 KB Output is correct
71 Correct 3 ms 1116 KB Output is correct
72 Correct 4 ms 1116 KB Output is correct
73 Correct 3 ms 1116 KB Output is correct
74 Correct 3 ms 1112 KB Output is correct
75 Correct 5 ms 1116 KB Output is correct
76 Correct 4 ms 1116 KB Output is correct
77 Correct 5 ms 1116 KB Output is correct
78 Correct 3 ms 1116 KB Output is correct
79 Correct 4 ms 1116 KB Output is correct
80 Correct 4 ms 1112 KB Output is correct
81 Correct 1 ms 344 KB Output is correct
82 Correct 4 ms 1116 KB Output is correct
83 Correct 4 ms 1288 KB Output is correct
84 Correct 3 ms 1368 KB Output is correct
85 Correct 4 ms 1116 KB Output is correct
86 Correct 3 ms 1112 KB Output is correct
87 Correct 4 ms 1116 KB Output is correct
88 Correct 4 ms 1116 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 4 ms 1116 KB Output is correct
91 Correct 5 ms 1372 KB Output is correct
92 Correct 4 ms 1116 KB Output is correct
93 Correct 4 ms 1176 KB Output is correct
94 Correct 4 ms 1112 KB Output is correct
95 Correct 4 ms 1116 KB Output is correct
96 Correct 3 ms 1112 KB Output is correct
97 Correct 4 ms 1116 KB Output is correct
98 Correct 4 ms 1308 KB Output is correct
99 Correct 4 ms 1384 KB Output is correct
100 Correct 4 ms 1112 KB Output is correct
101 Correct 4 ms 1116 KB Output is correct
102 Correct 4 ms 1148 KB Output is correct
103 Correct 1 ms 348 KB Output is correct
104 Correct 5 ms 1188 KB Output is correct
105 Correct 4 ms 1116 KB Output is correct
106 Correct 3 ms 1116 KB Output is correct
107 Correct 4 ms 1116 KB Output is correct
108 Correct 4 ms 1116 KB Output is correct
109 Correct 4 ms 1116 KB Output is correct
110 Correct 4 ms 1116 KB Output is correct
111 Correct 0 ms 348 KB Output is correct
112 Execution timed out 1089 ms 82072 KB Time limit exceeded
113 Halted 0 ms 0 KB -