Submission #945024

# Submission time Handle Problem Language Result Execution time Memory
945024 2024-03-13T10:02:36 Z Xiaoyang Fancy Fence (CEOI20_fancyfence) C++17
13 / 100
14 ms 3164 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
typedef long long ll;
 
#define fi first 
#define se second 
#define pll pair<ll,ll>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl;
#define MP make_pair
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()
#define endl "\n"
const ll inf=1e18;
ll lowbit(ll x){return x&(-x);}
 
const ll mod=1e9+7;
const ll maxn=1e5+5;
 
ll h[maxn],w[maxn];
 
ll c2(ll a){
	a%=mod;
	return ((a*(a-1))/2)%mod;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;cin>>n;
	ll wid=0;
	rep(i,1,n+1)cin>>h[i];
	rep(i,1,n+1)cin>>w[i],wid+=w[i],wid%=mod;
	
	ll ans=0;
	ans+=c2(wid+1);
	ans%=mod;
	//debug(ans);
	ll len=0;
	rep(i,1,n+1){
		//debug(i);
		if(h[i]==2){
			len+=w[i];
			len%=mod;
		}else{
			ans+=(2*c2(len+1))%mod;
			ans%=mod;
			len=0;
		}
		//debug(i);
	}
	if(len){
		ans+=(2*c2(len+1))%mod;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 7 ms 1624 KB Output is correct
4 Correct 14 ms 3160 KB Output is correct
5 Correct 13 ms 3164 KB Output is correct
6 Correct 13 ms 3096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -