Submission #1031329

#TimeUsernameProblemLanguageResultExecution timeMemory
1031329AbitoFlooding Wall (BOI24_wall)C++17
25 / 100
5059 ms21840 KiB
#include <bits/stdc++.h> #define F first #define S second #define pb push_back #define ppb pop_back #define ep insert #define endl '\n' #define elif else if #define pow pwr #define sqrt sqrtt #define int long long #define ll long long #define y1 YONE typedef unsigned long long ull; using namespace std; const int N=5e5+5,M=1e9+7; int a[N],n,b[N],p[N],c[2*N]; int32_t main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); p[0]=1; for (int i=1;i<N;i++) p[i]=p[i-1]*2%M; cin>>n; for (int i=1;i<=n;i++) cin>>a[i],c[i]=a[i]; for (int i=1;i<=n;i++) cin>>b[i],c[i+n]=b[i]; sort(c+1,c+1+2*n); int ans=0; for (int i=1;i<=n;i++){ for (int j=1;j<=2*n;j++){ if (c[j]==c[j-1]) continue; int l=1,r=1; for (int k=1;k<i;k++){ int x=(a[k]<c[j])+(b[k]<c[j]); l=l*x%M; } l=(p[i-1]-l+M)%M; for (int k=i+1;k<=n;k++){ int x=(a[k]<c[j])+(b[k]<c[j]); r=r*x%M; } r=(p[n-i]-r+M)%M; //cout<<i<<' '<<c[j]<<' '<<l<<' '<<r<<endl; l=l*r%M; if (a[i]<c[j]) ans=(ans+(l*(c[j]-c[j-1])%M))%M; if (b[i]<c[j]) ans=(ans+(l*(c[j]-c[j-1])%M))%M; } } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...