Submission #108394

#TimeUsernameProblemLanguageResultExecution timeMemory
108394nxteruBoat (APIO16_boat)C++14
9 / 100
1050 ms7032 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define M 1000000007 #define PB push_back ll n,a[505],b[505],dp[505][1005],s[1005][505],f[505],ans; vector<ll>cm; int main(void){ scanf("%lld",&n); f[1]=1; for(int i=2;i<n;i++)f[i]=M-(M/i)*f[M%i]%M; for(int i=0;i<n;i++){ scanf("%lld%lld",a+i,b+i); a[i]--; cm.PB(a[i]); cm.PB(b[i]); } sort(cm.begin(),cm.end()); cm.erase(unique(cm.begin(),cm.end()),cm.end()); for(int i=0;i<n;i++){ a[i]=lower_bound(cm.begin(),cm.end(),a[i])-cm.begin(); b[i]=lower_bound(cm.begin(),cm.end(),b[i])-cm.begin(); } for(int i=1;i<cm.size();i++){ ll p=cm[i]-cm[i-1]; s[i][0]=1; for(ll j=1;j<n;j++){ s[i][j]=s[i][j-1]*(p+j-1LL)%M*f[j]%M; } } for(int i=0;i<n;i++){ ll p=1; for(int j=1;j<=b[i];j++){ if(j>a[i]){ dp[i][j]=p; ans=(ans+p)%M; } for(int k=0;k<i;k++)p=(p+dp[k][j]*s[j][i-k]%M)%M; } } printf("%lld\n",ans); }

Compilation message (stderr)

boat.cpp: In function 'int main()':
boat.cpp:24:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1;i<cm.size();i++){
              ~^~~~~~~~~~
boat.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
boat.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld",a+i,b+i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...