# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
577548 | 2022-06-15T04:22:59 Z | temporary_juggernaut | Fancy Fence (CEOI20_fancyfence) | C++14 | 68 ms | 18608 KB |
#include<bits/stdc++.h> #define fr first #define sc second using namespace std; typedef long long ll; typedef long double ld; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef juggernaut #define printl(args...) printf(args) #else #define printl(args...) 0 #endif int h[100005]; int w[100005]; ll pref[100005]; int n; ll mod=1e9+7; const ll cn=(mod+1)/2; pair<int,int>sp[100005][17]; int logs[100005]; int get(int l,int r){ int len=logs[r-l+1]; return min(sp[l][len],sp[r-(1<<len)+1][len]).sc; } ll ans; void go(int l,int r){ if(l>r)return; int pos=get(l,r); ll A=w[pos]; ll B=h[pos]; ans+=A*(A+1)/2%mod*((B*(B+1)/2)%mod)%mod; ans%=mod; B=B*(B+1)/2%mod; ans+=B*((pref[pos-1]-pref[l-1])%mod)%mod*((pref[r]-pref[pos])%mod)%mod; ans%=mod; ans+=B*A%mod*((pref[r]-pref[l-1]-A)%mod)%mod; ans%=mod; go(l,pos-1); go(pos+1,r); } int main(){ scanf("%d",&n); logs[0]--; for(int i=1;i<=n;i++){ scanf("%d",&h[i]); logs[i]=logs[i>>1]+1; sp[i][0]=make_pair(h[i],i); } for(int j=1;j<17;j++) for(int i=1;i+(1<<j)-1<=n;i++)sp[i][j]=min(sp[i][j-1],sp[i+(1<<(j-1))][j-1]); for(int i=1;i<=n;i++){ scanf("%d",&w[i]); pref[i]=pref[i-1]; pref[i]+=w[i]; } go(1,n); cout<<ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 26 ms | 7876 KB | Output is correct |
4 | Correct | 54 ms | 15660 KB | Output is correct |
5 | Correct | 46 ms | 15540 KB | Output is correct |
6 | Correct | 47 ms | 15544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 4 ms | 1748 KB | Output is correct |
3 | Correct | 22 ms | 7912 KB | Output is correct |
4 | Correct | 55 ms | 15508 KB | Output is correct |
5 | Correct | 55 ms | 15436 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 4 ms | 1748 KB | Output is correct |
4 | Correct | 21 ms | 7888 KB | Output is correct |
5 | Correct | 53 ms | 15544 KB | Output is correct |
6 | Correct | 48 ms | 15452 KB | Output is correct |
7 | Correct | 1 ms | 396 KB | Output is correct |
8 | Correct | 5 ms | 1748 KB | Output is correct |
9 | Correct | 27 ms | 7892 KB | Output is correct |
10 | Correct | 53 ms | 15452 KB | Output is correct |
11 | Correct | 49 ms | 15604 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 328 KB | Output is correct |
8 | Correct | 1 ms | 468 KB | Output is correct |
9 | Correct | 1 ms | 468 KB | Output is correct |
10 | Correct | 1 ms | 468 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 468 KB | Output is correct |
14 | Correct | 1 ms | 468 KB | Output is correct |
15 | Correct | 1 ms | 468 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 468 KB | Output is correct |
11 | Correct | 20 ms | 7892 KB | Output is correct |
12 | Correct | 65 ms | 15436 KB | Output is correct |
13 | Correct | 64 ms | 15432 KB | Output is correct |
14 | Correct | 53 ms | 15452 KB | Output is correct |
15 | Correct | 1 ms | 468 KB | Output is correct |
16 | Correct | 5 ms | 1748 KB | Output is correct |
17 | Correct | 25 ms | 7952 KB | Output is correct |
18 | Correct | 50 ms | 15436 KB | Output is correct |
19 | Correct | 55 ms | 15464 KB | Output is correct |
20 | Correct | 1 ms | 468 KB | Output is correct |
21 | Correct | 7 ms | 1772 KB | Output is correct |
22 | Correct | 30 ms | 7816 KB | Output is correct |
23 | Correct | 49 ms | 15436 KB | Output is correct |
24 | Correct | 52 ms | 15544 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 468 KB | Output is correct |
28 | Correct | 1 ms | 468 KB | Output is correct |
29 | Correct | 1 ms | 468 KB | Output is correct |
30 | Correct | 5 ms | 1748 KB | Output is correct |
31 | Correct | 5 ms | 1748 KB | Output is correct |
32 | Correct | 25 ms | 7936 KB | Output is correct |
33 | Correct | 29 ms | 7840 KB | Output is correct |
34 | Correct | 52 ms | 15516 KB | Output is correct |
35 | Correct | 52 ms | 15548 KB | Output is correct |
36 | Correct | 56 ms | 15524 KB | Output is correct |
37 | Correct | 66 ms | 15448 KB | Output is correct |
38 | Correct | 1 ms | 212 KB | Output is correct |
39 | Correct | 58 ms | 15544 KB | Output is correct |
40 | Correct | 58 ms | 15564 KB | Output is correct |
41 | Correct | 60 ms | 16172 KB | Output is correct |
42 | Correct | 68 ms | 18608 KB | Output is correct |