Submission #142987

#TimeUsernameProblemLanguageResultExecution timeMemory
142987IC_COLDSTOPBoat (APIO16_boat)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define int ll #define MP make_pair #define pb push_back #define F first #define S second #define pii pair<int,int> #define REP(i,a,b) for(int i=a; i<b; i++) const int MX=5e2+3, mod=1e9+7; int n, m, dp[10][MX*2][2*MX], l[MX], r[MX], num[2*MX], p[MX*2]; map<int,int> mark; vector<int> vec; int32_t main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); REP(i,1,MX*2) p[i]=pw(i,mod-2); cin>>n; REP(i,0,n){ cin>>l[i]>>r[i]; r[i]++; if(!mark[l[i]]) mark[l[i]]=1, vec.pb(l[i]); if(!mark[r[i]]) mark[r[i]]=1, vec.pb(r[i]); } m=vec.size(); sort(vec.begin(), vec.end()); int mm=0; dp[mm][0][0]=1; REP(j,1,m){ dp[mm][j][0]=dp[mm][j-1][0]+dp[mm][j-1][1]; if(l[0]<vec[j] && r[0]>=vec[j]) dp[mm][j][1]=(vec[j]-vec[j-1])%mod, num[j]++; } REP(i,1,n){ mm^=1; REP(j,1,m){ dp[mm][j][0]=0; if(j>1) REP(w,0,num[j-1]+1) dp[mm][j][0]=(dp[mm][j-1][w]+dp[mm][j][0])%mod; else dp[mm][j][0]=1; int flg=0, cnt=vec[j]-vec[j-1]; if(l[i]<vec[j] && r[i]>=vec[j]) flg=1, num[j]++; REP(w,1,num[j]+1){ dp[mm][j][w]=dp[mm^1][j][w]; if(flg) dp[mm][j][w]=((ll)dp[mm][j][w] + (ll)dp[mm^1][j][w-1] * (cnt-w+1) %mod * p[w]%mod )%mod; } } } int sum=0; REP(w,0,MX*2) sum=(sum+dp[mm][m-1][w])%mod; cout<<sum-1<<endl; return 0; }

Compilation message (stderr)

boat.cpp: In function 'int32_t main()':
boat.cpp:20:21: error: 'pw' was not declared in this scope
  REP(i,1,MX*2) p[i]=pw(i,mod-2);
                     ^~
boat.cpp:20:21: note: suggested alternative: 'p'
  REP(i,1,MX*2) p[i]=pw(i,mod-2);
                     ^~
                     p