Submission #1041189

#TimeUsernameProblemLanguageResultExecution timeMemory
1041189ilovveyyouTrains (BOI24_trains)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define mp(x, y) make_pair(x, y) #define sz(v) ((int) (v).size()) #define all(v) (v).begin(), (v).end() #define MASK(i) (1LL << (i)) #define BIT(x, y) (((x) >> (y)) & 1) #define clz __builtin_clzll #define ctz __builtin_ctzll #define popcount __builtin_popcount #define lg(x) (63 - clz(x)) template <class X, class Y> inline bool maximize(X &x, Y y) { return (x < y ? x = y, true : false); } template <class X, class Y> inline bool minimize(X &x, Y y) { return (x > y ? x = y, true : false); } template <class X> inline void compress(vector<X> &a) { sort(all(a)); a.resize(unique(all(a)) - a.begin()); } const ll oo = (ll) 1e18, inf = (ll) 1e9, mod = (ll) 1e9 + 7; const int mxn = (int) 2e5 + 5, S = (int) 450, S2 = (int) 450, lg = (int) 17; void add(ll &x, ll y) { x += y; if (x >= mod) x -= mod; } void sub(ll &x, ll y) { x -= y; if (x < 0) x += mod; } int n; pair<ll, ll> a[mxn]; ll f[mxn + S]; ll calc[mxn + S][S+1]; void solve() { cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i].se >> a[i].fi; minimize(a[i].se, n + 1); minimize(a[i].fi, n + 1); } for (int i = n; i >= 1; --i) { f[i] = 1; if (a[i].fi <= S) { if (a[i].se) { for (int j = 1; j <= a[i].fi; ++j) { if (i + j * a[i].se > n) break; add(f[i], f[i + j * a[i].se]); } } } else { if (a[i].se > S) { for (int j = 1; j <= a[i].fi; ++j) { if (i + j * a[i].se > n) break; add(f[i], f[i + j * a[i].se]); } } else { if (a[i].se) { add(f[i], calc[i + a[i].se][a[i].se]); sub(f[i], calc[min(n, a[i].se * a[i].fi) + 1][a[i].se]); } } } for (int d = 1; d <= S; ++d) { add(calc[i][d], f[i]); add(calc[i][d], calc[i + d][d]); } // cout << f[i] << ' '; } cout << f[1]; return; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define TASK "task" if (fopen(TASK".inp", "r")) { freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout); } int t = 1; // cin >> t; while (t--) { solve(); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:82:60: error: no matching function for call to 'min(int&, long long int)'
   82 |                     sub(f[i], calc[min(n, a[i].se * a[i].fi) + 1][a[i].se]);
      |                                                            ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:82:60: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   82 |                     sub(f[i], calc[min(n, a[i].se * a[i].fi) + 1][a[i].se]);
      |                                                            ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:82:60: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   82 |                     sub(f[i], calc[min(n, a[i].se * a[i].fi) + 1][a[i].se]);
      |                                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
Main.cpp:82:60: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |                     sub(f[i], calc[min(n, a[i].se * a[i].fi) + 1][a[i].se]);
      |                                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp:82:60: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |                     sub(f[i], calc[min(n, a[i].se * a[i].fi) + 1][a[i].se]);
      |                                                            ^
Main.cpp: In function 'int main()':
Main.cpp:106:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |         freopen(TASK".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:107:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  107 |         freopen(TASK".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~