답안 #958029

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
958029 2024-04-04T17:19:21 Z Zena_Hossam Cryptography (NOI20_crypto) C++14
100 / 100
541 ms 52840 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>d;
    ll m[n+5]={};ll dd[n+5]={};
    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:52:8: warning: unused variable 'k' [-Wunused-variable]
   52 |     ll k[n+5]={};ll c=0;
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 ms 348 KB Output is correct
10 Correct 0 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 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 347 ms 49720 KB Output is correct
3 Correct 432 ms 49488 KB Output is correct
4 Correct 372 ms 49648 KB Output is correct
5 Correct 370 ms 49744 KB Output is correct
6 Correct 441 ms 49596 KB Output is correct
7 Correct 399 ms 49748 KB Output is correct
8 Correct 406 ms 49516 KB Output is correct
9 Correct 397 ms 49512 KB Output is correct
10 Correct 381 ms 49672 KB Output is correct
11 Correct 382 ms 49972 KB Output is correct
12 Correct 367 ms 49540 KB Output is correct
13 Correct 419 ms 49612 KB Output is correct
14 Correct 360 ms 49624 KB Output is correct
15 Correct 401 ms 49536 KB Output is correct
16 Correct 396 ms 49744 KB Output is correct
17 Correct 400 ms 49536 KB Output is correct
18 Correct 391 ms 49832 KB Output is correct
19 Correct 372 ms 49712 KB Output is correct
20 Correct 360 ms 49724 KB Output is correct
21 Correct 359 ms 49624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 357 ms 49744 KB Output is correct
3 Correct 429 ms 49540 KB Output is correct
4 Correct 376 ms 49628 KB Output is correct
5 Correct 381 ms 49748 KB Output is correct
6 Correct 399 ms 49600 KB Output is correct
7 Correct 395 ms 49520 KB Output is correct
8 Correct 510 ms 49740 KB Output is correct
9 Correct 403 ms 49944 KB Output is correct
10 Correct 377 ms 49560 KB Output is correct
11 Correct 384 ms 49504 KB Output is correct
12 Correct 382 ms 49560 KB Output is correct
13 Correct 355 ms 49888 KB Output is correct
14 Correct 372 ms 49624 KB Output is correct
15 Correct 368 ms 49692 KB Output is correct
16 Correct 388 ms 49584 KB Output is correct
17 Correct 365 ms 49732 KB Output is correct
18 Correct 378 ms 49764 KB Output is correct
19 Correct 377 ms 49580 KB Output is correct
20 Correct 407 ms 49544 KB Output is correct
21 Correct 376 ms 49732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 2 ms 852 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 2 ms 796 KB Output is correct
8 Correct 3 ms 860 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 2 ms 860 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 2 ms 860 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 736 KB Output is correct
17 Correct 2 ms 860 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 2 ms 860 KB Output is correct
20 Correct 2 ms 860 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
22 Correct 2 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 ms 348 KB Output is correct
10 Correct 0 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 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 2 ms 852 KB Output is correct
28 Correct 2 ms 860 KB Output is correct
29 Correct 2 ms 860 KB Output is correct
30 Correct 2 ms 860 KB Output is correct
31 Correct 2 ms 796 KB Output is correct
32 Correct 3 ms 860 KB Output is correct
33 Correct 2 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 860 KB Output is correct
36 Correct 2 ms 860 KB Output is correct
37 Correct 2 ms 860 KB Output is correct
38 Correct 2 ms 860 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 2 ms 736 KB Output is correct
41 Correct 2 ms 860 KB Output is correct
42 Correct 2 ms 860 KB Output is correct
43 Correct 2 ms 860 KB Output is correct
44 Correct 2 ms 860 KB Output is correct
45 Correct 2 ms 860 KB Output is correct
46 Correct 2 ms 860 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 2 ms 860 KB Output is correct
49 Correct 2 ms 860 KB Output is correct
50 Correct 2 ms 860 KB Output is correct
51 Correct 2 ms 860 KB Output is correct
52 Correct 2 ms 856 KB Output is correct
53 Correct 2 ms 860 KB Output is correct
54 Correct 3 ms 860 KB Output is correct
55 Correct 2 ms 860 KB Output is correct
56 Correct 2 ms 860 KB Output is correct
57 Correct 2 ms 860 KB Output is correct
58 Correct 2 ms 860 KB Output is correct
59 Correct 2 ms 860 KB Output is correct
60 Correct 2 ms 856 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 2 ms 860 KB Output is correct
63 Correct 2 ms 860 KB Output is correct
64 Correct 2 ms 860 KB Output is correct
65 Correct 2 ms 808 KB Output is correct
66 Correct 2 ms 860 KB Output is correct
67 Correct 2 ms 860 KB Output is correct
68 Correct 2 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 357 ms 49744 KB Output is correct
3 Correct 429 ms 49540 KB Output is correct
4 Correct 376 ms 49628 KB Output is correct
5 Correct 381 ms 49748 KB Output is correct
6 Correct 399 ms 49600 KB Output is correct
7 Correct 395 ms 49520 KB Output is correct
8 Correct 510 ms 49740 KB Output is correct
9 Correct 403 ms 49944 KB Output is correct
10 Correct 377 ms 49560 KB Output is correct
11 Correct 384 ms 49504 KB Output is correct
12 Correct 382 ms 49560 KB Output is correct
13 Correct 355 ms 49888 KB Output is correct
14 Correct 372 ms 49624 KB Output is correct
15 Correct 368 ms 49692 KB Output is correct
16 Correct 388 ms 49584 KB Output is correct
17 Correct 365 ms 49732 KB Output is correct
18 Correct 378 ms 49764 KB Output is correct
19 Correct 377 ms 49580 KB Output is correct
20 Correct 407 ms 49544 KB Output is correct
21 Correct 376 ms 49732 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 2 ms 860 KB Output is correct
24 Correct 2 ms 852 KB Output is correct
25 Correct 2 ms 860 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 2 ms 860 KB Output is correct
28 Correct 2 ms 796 KB Output is correct
29 Correct 3 ms 860 KB Output is correct
30 Correct 2 ms 860 KB Output is correct
31 Correct 2 ms 860 KB Output is correct
32 Correct 2 ms 860 KB Output is correct
33 Correct 2 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 860 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 2 ms 736 KB Output is correct
38 Correct 2 ms 860 KB Output is correct
39 Correct 2 ms 860 KB Output is correct
40 Correct 2 ms 860 KB Output is correct
41 Correct 2 ms 860 KB Output is correct
42 Correct 2 ms 860 KB Output is correct
43 Correct 2 ms 860 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 493 ms 49736 KB Output is correct
46 Correct 446 ms 51648 KB Output is correct
47 Correct 518 ms 51640 KB Output is correct
48 Correct 521 ms 51552 KB Output is correct
49 Correct 454 ms 51448 KB Output is correct
50 Correct 444 ms 51524 KB Output is correct
51 Correct 541 ms 51716 KB Output is correct
52 Correct 440 ms 51540 KB Output is correct
53 Correct 429 ms 51648 KB Output is correct
54 Correct 414 ms 51508 KB Output is correct
55 Correct 444 ms 51696 KB Output is correct
56 Correct 494 ms 51516 KB Output is correct
57 Correct 491 ms 51540 KB Output is correct
58 Correct 1 ms 348 KB Output is correct
59 Correct 426 ms 51464 KB Output is correct
60 Correct 489 ms 52044 KB Output is correct
61 Correct 470 ms 51556 KB Output is correct
62 Correct 468 ms 51452 KB Output is correct
63 Correct 468 ms 51704 KB Output is correct
64 Correct 456 ms 51536 KB Output is correct
65 Correct 476 ms 51556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 ms 348 KB Output is correct
10 Correct 0 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 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 347 ms 49720 KB Output is correct
27 Correct 432 ms 49488 KB Output is correct
28 Correct 372 ms 49648 KB Output is correct
29 Correct 370 ms 49744 KB Output is correct
30 Correct 441 ms 49596 KB Output is correct
31 Correct 399 ms 49748 KB Output is correct
32 Correct 406 ms 49516 KB Output is correct
33 Correct 397 ms 49512 KB Output is correct
34 Correct 381 ms 49672 KB Output is correct
35 Correct 382 ms 49972 KB Output is correct
36 Correct 367 ms 49540 KB Output is correct
37 Correct 419 ms 49612 KB Output is correct
38 Correct 360 ms 49624 KB Output is correct
39 Correct 401 ms 49536 KB Output is correct
40 Correct 396 ms 49744 KB Output is correct
41 Correct 400 ms 49536 KB Output is correct
42 Correct 391 ms 49832 KB Output is correct
43 Correct 372 ms 49712 KB Output is correct
44 Correct 360 ms 49724 KB Output is correct
45 Correct 359 ms 49624 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 357 ms 49744 KB Output is correct
48 Correct 429 ms 49540 KB Output is correct
49 Correct 376 ms 49628 KB Output is correct
50 Correct 381 ms 49748 KB Output is correct
51 Correct 399 ms 49600 KB Output is correct
52 Correct 395 ms 49520 KB Output is correct
53 Correct 510 ms 49740 KB Output is correct
54 Correct 403 ms 49944 KB Output is correct
55 Correct 377 ms 49560 KB Output is correct
56 Correct 384 ms 49504 KB Output is correct
57 Correct 382 ms 49560 KB Output is correct
58 Correct 355 ms 49888 KB Output is correct
59 Correct 372 ms 49624 KB Output is correct
60 Correct 368 ms 49692 KB Output is correct
61 Correct 388 ms 49584 KB Output is correct
62 Correct 365 ms 49732 KB Output is correct
63 Correct 378 ms 49764 KB Output is correct
64 Correct 377 ms 49580 KB Output is correct
65 Correct 407 ms 49544 KB Output is correct
66 Correct 376 ms 49732 KB Output is correct
67 Correct 0 ms 344 KB Output is correct
68 Correct 2 ms 860 KB Output is correct
69 Correct 2 ms 852 KB Output is correct
70 Correct 2 ms 860 KB Output is correct
71 Correct 2 ms 860 KB Output is correct
72 Correct 2 ms 860 KB Output is correct
73 Correct 2 ms 796 KB Output is correct
74 Correct 3 ms 860 KB Output is correct
75 Correct 2 ms 860 KB Output is correct
76 Correct 2 ms 860 KB Output is correct
77 Correct 2 ms 860 KB Output is correct
78 Correct 2 ms 860 KB Output is correct
79 Correct 2 ms 860 KB Output is correct
80 Correct 2 ms 860 KB Output is correct
81 Correct 0 ms 348 KB Output is correct
82 Correct 2 ms 736 KB Output is correct
83 Correct 2 ms 860 KB Output is correct
84 Correct 2 ms 860 KB Output is correct
85 Correct 2 ms 860 KB Output is correct
86 Correct 2 ms 860 KB Output is correct
87 Correct 2 ms 860 KB Output is correct
88 Correct 2 ms 860 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 2 ms 860 KB Output is correct
91 Correct 2 ms 860 KB Output is correct
92 Correct 2 ms 860 KB Output is correct
93 Correct 2 ms 860 KB Output is correct
94 Correct 2 ms 856 KB Output is correct
95 Correct 2 ms 860 KB Output is correct
96 Correct 3 ms 860 KB Output is correct
97 Correct 2 ms 860 KB Output is correct
98 Correct 2 ms 860 KB Output is correct
99 Correct 2 ms 860 KB Output is correct
100 Correct 2 ms 860 KB Output is correct
101 Correct 2 ms 860 KB Output is correct
102 Correct 2 ms 856 KB Output is correct
103 Correct 0 ms 348 KB Output is correct
104 Correct 2 ms 860 KB Output is correct
105 Correct 2 ms 860 KB Output is correct
106 Correct 2 ms 860 KB Output is correct
107 Correct 2 ms 808 KB Output is correct
108 Correct 2 ms 860 KB Output is correct
109 Correct 2 ms 860 KB Output is correct
110 Correct 2 ms 860 KB Output is correct
111 Correct 1 ms 348 KB Output is correct
112 Correct 493 ms 49736 KB Output is correct
113 Correct 446 ms 51648 KB Output is correct
114 Correct 518 ms 51640 KB Output is correct
115 Correct 521 ms 51552 KB Output is correct
116 Correct 454 ms 51448 KB Output is correct
117 Correct 444 ms 51524 KB Output is correct
118 Correct 541 ms 51716 KB Output is correct
119 Correct 440 ms 51540 KB Output is correct
120 Correct 429 ms 51648 KB Output is correct
121 Correct 414 ms 51508 KB Output is correct
122 Correct 444 ms 51696 KB Output is correct
123 Correct 494 ms 51516 KB Output is correct
124 Correct 491 ms 51540 KB Output is correct
125 Correct 1 ms 348 KB Output is correct
126 Correct 426 ms 51464 KB Output is correct
127 Correct 489 ms 52044 KB Output is correct
128 Correct 470 ms 51556 KB Output is correct
129 Correct 468 ms 51452 KB Output is correct
130 Correct 468 ms 51704 KB Output is correct
131 Correct 456 ms 51536 KB Output is correct
132 Correct 476 ms 51556 KB Output is correct
133 Correct 0 ms 344 KB Output is correct
134 Correct 492 ms 52636 KB Output is correct
135 Correct 476 ms 52816 KB Output is correct
136 Correct 539 ms 52584 KB Output is correct
137 Correct 473 ms 52772 KB Output is correct
138 Correct 477 ms 52636 KB Output is correct
139 Correct 500 ms 52648 KB Output is correct
140 Correct 517 ms 52468 KB Output is correct
141 Correct 446 ms 52648 KB Output is correct
142 Correct 532 ms 52544 KB Output is correct
143 Correct 519 ms 52652 KB Output is correct
144 Correct 521 ms 52512 KB Output is correct
145 Correct 537 ms 52648 KB Output is correct
146 Correct 526 ms 52840 KB Output is correct
147 Correct 0 ms 348 KB Output is correct
148 Correct 537 ms 52508 KB Output is correct
149 Correct 478 ms 52508 KB Output is correct
150 Correct 491 ms 52664 KB Output is correct
151 Correct 496 ms 52568 KB Output is correct
152 Correct 498 ms 52508 KB Output is correct
153 Correct 490 ms 52404 KB Output is correct
154 Correct 470 ms 52456 KB Output is correct