답안 #944880

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
944880 2024-03-13T07:17:57 Z Xiaoyang Fancy Fence (CEOI20_fancyfence) C++17
0 / 100
0 ms 600 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];

int expo(int a, int b,int m){
    if(b==0){
        return 1;
    }
    int x=expo(a,b/2,m);
    if(b%2==0){
        return (x%m*x%m)%m;
    }
    return ((a%m)*(x%m)*(x%m))%m;
}

ll c2(ll a){
	ll tmp=((a%mod)*(a-1)%mod)%mod;
	return (tmp%mod+expo(2,mod-2,mod))%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+=wid+c2(wid);
	ans%=mod;
	//debug(ans);
	
	rep(i,1,n+1){
		if(h[i]==2){
			ll len=0;
			while(h[i]==2){
				len+=w[i];
				len%=mod;
				i++;
			}
			ans+=2*len+2*c2(len);
			ans%=mod;
		}
	}
	cout<<ans<<endl;
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -