Submission #745208

# Submission time Handle Problem Language Result Execution time Memory
745208 2023-05-19T14:52:32 Z amirhoseinfar1385 Boat (APIO16_boat) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;

long long mypow(long long m,long long y){
	if(y==0){
		return 1;
	}
	long long p=mypow(m,(y>>1));
	p*=p;
	p%=mod;
	if(y&1){
		p*=m;
		p%=mod;
	}
	return p;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<long long>rev(n+6);
	for(int i=0;i<=n+5;i++){
		rev[i]=mypow(i,mod-2);
	}
	vector<pair<int,int>>all(n+1);
	vector<int>allind;
	for(int i=1;i<=n;i++){
		cin>>all[i].first>>all[i].second;
		allind.push_back(all[i].first);
		allind.push_back(all[i].second);
		allind.push_back(all[i].first+1);
		allind.push_back(all[i].first-1);
		allind.push_back(all[i].second+1);
		allind.push_back(all[i].second-1);
	}
	allind.push_back(0);
	sort(allind.begin(),allind.end());
	allind.resize(unique(allind.begin(),allind.end())-allind.begin());
	int sz=(int)allind.size()+5;
	vector<vector<long long>>dp(sz+10,vector<long long>(sz+10));
	vector<long long>ps(sz+10);
	dp[0][0]=1;
	for(int i=0;i<sz+10;i++){
		ps[i]=1;
	}
	for(int i=1;i<=n;i++){
		int l=lower_bound(allind.begin(),allind.end(),all[i].first)-allind.begin();
		int r=lower_bound(allind.begin(),allind.end(),all[i].second)-allind.begin();
		for(int j=l;j<=r;j++){
			long long cnt=allind[j]-allind[j-1];
			for(int h=n;h>=2;h--){
				dp[j][h]+=dp[j][h-1]*(cnt-(h-1))%mod*rev[h]%mod;
				dp[j][h]=ww(dp[j][h]);
			}
			dp[j][1]+=ps[j-1]*cnt%mod;
			dp[j][1]=ww(dp[j][1]);
		}
		ps[0]=dp[0][0];
		for(int i=1;i<=sz+9;i++){
			ps[i]=ps[i-1];
			for(int h=0;h<=n;h++){
				ps[i]+=dp[i][h];
			}
			ps[i]%=mod;
		}
	}
	long long res=ps[sz+8];
	res+=mod-1;
	res%=mod;
	cout<<res<<"\n";
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:57:14: error: 'ww' was not declared in this scope
   57 |     dp[j][h]=ww(dp[j][h]);
      |              ^~
boat.cpp:60:13: error: 'ww' was not declared in this scope
   60 |    dp[j][1]=ww(dp[j][1]);
      |             ^~