Submission #48379

#TimeUsernameProblemLanguageResultExecution timeMemory
48379BTheroBoat (APIO16_boat)C++17
9 / 100
2061 ms524288 KiB
// Why am I so stupid? :c #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second typedef long long ll; using namespace std; const int mod = 1e9+7; pair <int, int> l[505]; pair <int, int> r[505]; int dp[2][1000005]; int dp2[1000005]; int rl[1005]; int n, m; int ans; int now; void addMod(int &a, int b) { a += b; if (mod <= a) { a -= mod; } } void compress() { vector <int> vv; for (int i = 1; i <= n; ++i) { for (int j = l[i].fi; j <= r[i].fi; ++j) { vv.pb(j); } } sort(all(vv)); vv.resize(unique(all(vv)) - vv.begin()); m = vv.size(); for (int i = 1; i <= n; ++i) { l[i].se = upper_bound(all(vv), l[i].fi) - vv.begin(); r[i].se = upper_bound(all(vv), r[i].fi) - vv.begin(); } } void solve() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d %d", &l[i].fi, &r[i].fi); } compress(); for (int i = 1; i <= n; ++i) { now ^= 1; for (int j = l[i].se; j <= r[i].se; ++j) { dp[now][j] = 1; } for (int j = l[i].se; j <= r[i].se; ++j) { for (int k = 1; k < j; ++k) { addMod(dp[now][j], dp2[k]); } } for (int j = l[i].se; j <= r[i].se; ++j) { addMod(dp2[j], dp[now][j]); } } for (int i = 1; i <= m; ++i) { addMod(ans, dp2[i]); } printf("%d\n", ans); } int main() { #ifdef BThero freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // BThero int tt = 1; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

boat.cpp: In function 'void solve()':
boat.cpp:63:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
boat.cpp:66:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &l[i].fi, &r[i].fi);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...