Submission #760366

#TimeUsernameProblemLanguageResultExecution timeMemory
760366Username4132Boat (APIO16_boat)C++14
0 / 100
7 ms2260 KiB
#include<iostream> #include<algorithm> #include<vector> using namespace std; using ll = long long; #define forn(i, n) for(int i=0; i<(int)n; ++i) #define forsn(i, s, n) for(int i=s; i<(int)n; ++i) #define PB push_back const int MAXN=510, INF=1000000009, MOD=1000000007; int n, m, ans, le[MAXN], ri[MAXN], dp[MAXN][MAXN], sum[MAXN][MAXN]; vector<int> pt; int main(){ scanf("%d", &n); forn(i, n){ scanf("%d %d", le+i, ri+i); pt.PB(le[i]), pt.PB(ri[i]); pt.PB(le[i]+1), pt.PB(ri[i]-1); } pt.PB(-1), pt.PB(INF); sort(pt.begin(), pt.end()); pt.erase(unique(pt.begin(), pt.end()), pt.end()); m = pt.size(); forn(i, n) forsn(j, 1, m){ if(pt[j]<=ri[i] && pt[j]>=le[i]){ dp[i][j]=1; forn(k, i){ dp[i][j] = ((ll)dp[i][j] + (ll)sum[k][j-1] + ((ll)(min(ri[k]+1, pt[j]) - max(pt[j-1], le[k])))*dp[k][j-1])%MOD; } } sum[i][j]=(sum[i][j-1]+((ll)(min(ri[i]+1, pt[j]) - max(pt[j-1], le[i])))*dp[i][j-1])%MOD; } forn(i, n) ans=(ans+sum[i][m-1])%MOD; printf("%d\n", ans); }

Compilation message (stderr)

boat.cpp: In function 'int main()':
boat.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
boat.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d %d", le+i, ri+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...