Submission #967912

#TimeUsernameProblemLanguageResultExecution timeMemory
967912duckindogBoat (APIO16_boat)C++17
9 / 100
2041 ms524288 KiB
#include <bits/stdc++.h> using namespace std; const int N = 500 + 10, M = 1'000'000'007; int n; int a[N], b[N]; int f[2][1'000'010]; auto add(auto& x, const auto& y) { x = (x + y) % M; } int32_t main() { cin.tie(0)->sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i] >> b[i]; vector<int> rrh; for (int i = 1; i <= n; ++i) { for (int j = a[i]; j <= b[i]; ++j) rrh.push_back(j); } sort(rrh.begin(), rrh.end()); rrh.resize(unique(rrh.begin(), rrh.end()) - rrh.begin()); f[0][0] = 1; for (int i = 1; i <= n; ++i) { int id = i & 1, p = id ^ 1; for (int j = 0; j <= rrh.size(); ++j) f[id][j] = 0; int it = lower_bound(rrh.begin(), rrh.end(), a[i]) - rrh.begin() + 1; for (int j = 0; j <= rrh.size(); ++j) f[id][j] = f[p][j]; for (int j = it; j <= b[i] - a[i] + it; ++j) { for (int t = 0; t < j; ++t) add(f[id][j], f[p][t]); } } int answer = 0; for (int i = 1; i <= rrh.size(); ++i) add(answer, f[n & 1][i]); cout << answer << "\n"; }

Compilation message (stderr)

boat.cpp:11:10: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   11 | auto add(auto& x, const auto& y) {
      |          ^~~~
boat.cpp:11:25: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   11 | auto add(auto& x, const auto& y) {
      |                         ^~~~
boat.cpp: In function 'int32_t main()':
boat.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for (int j = 0; j <= rrh.size(); ++j) f[id][j] = 0;
      |                     ~~^~~~~~~~~~~~~
boat.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int j = 0; j <= rrh.size(); ++j) f[id][j] = f[p][j];
      |                     ~~^~~~~~~~~~~~~
boat.cpp:44:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for (int i = 1; i <= rrh.size(); ++i) add(answer, f[n & 1][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...