Submission #1033702

#TimeUsernameProblemLanguageResultExecution timeMemory
1033702anHiepTrains (BOI24_trains)C++14
Compilation error
0 ms0 KiB
//#pragma GCC optimize("O3,unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define ll long long #define ii pair<int, int> #define vi vector<int> #define vll vector<ll> #define vii vector<ii> #define cd complex<double> #define ld long double #define all(x) (x).begin(), (x).end() #define iii tuple<int, int, int> const ll mod = 1e9 + 7; const ll INF = 1e18L + 5; const double PI = acos(-1); const int block = 320; const int N = 1e5; int tc, tt = 1; int n; ll d[N + 5], x[N + 5]; namespace sub1 { bool ck() { return n <= 15; } ll dp[N + 5]; void sol() { dp[1] = 1; for(int i=1; i<=n; i++) if(d[i] != 0) { for(int j=i + d[i]; j<=min(n, i + x[i] * d[i]); j+=d[i]) dp[j] = (dp[j] + dp[i]) % mod; } ll ans = 0; for(int i=1; i<=n; i++) ans = (ans + dp[i]) % mod; cout<<ans; } } namespace sub2 { bool ck() { return true; } struct node { ll i, j, d; }; ll dp[N + 5], sum[block + 100][block + 100]; vector<node> end[N + 5]; void sol() { memset(sum, 0, sizeof(sum)); dp[1] = 1; for(int i=1; i<=n; i++) { for(int j=1; j<=block; j++) dp[i] = (dp[i] + sum[j][i % j]) % mod; for(auto x: end[i]) sum[x.i][x.j] = (sum[x.i][x.j] + mod - x.d) % mod; if(d[i] == 0) continue; if(d[i] > block) { for(int j=i + d[i]; j<=min(n, i + x[i] * d[i]); j+=d[i]) dp[j] = (dp[j] + dp[i]) % mod; } else { if(x[i] == 0) continue; if(i + x[i] * d[i] <= n) end[i + x[i] * d[i]].pb({d[i], i % d[i], dp[i]}); sum[d[i]][i % d[i]] = (sum[d[i]][i % d[i]] + dp[i]) % mod; } } ll ans = 0; for(int i=1; i<=n; i++) ans = (ans + dp[i]) % mod; cout<<ans; } } void solve() { cin>>n; for(int i=1; i<=n; i++) cin>>d[i]>>x[i]; if(sub1::ck()) {sub1::sol(); return;} if(sub2::ck()) {sub2::sol(); return;} } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); for(tc=1; tc<=tt; tc++) solve(); cerr<<"\nTime elapsed: "<<1000.0*clock()/CLOCKS_PER_SEC<<" ms.\n"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'void sub1::sol()':
Main.cpp:38:58: error: no matching function for call to 'min(int&, long long int)'
   38 |             for(int j=i + d[i]; j<=min(n, i + x[i] * d[i]); j+=d[i])
      |                                                          ^
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:4:
/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:38:58: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   38 |             for(int j=i + d[i]; j<=min(n, i + x[i] * d[i]); j+=d[i])
      |                                                          ^
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:4:
/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:38:58: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   38 |             for(int j=i + d[i]; j<=min(n, i + x[i] * d[i]); j+=d[i])
      |                                                          ^
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:4:
/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:38:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |             for(int j=i + d[i]; j<=min(n, i + x[i] * d[i]); j+=d[i])
      |                                                          ^
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:4:
/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:38:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |             for(int j=i + d[i]; j<=min(n, i + x[i] * d[i]); j+=d[i])
      |                                                          ^
Main.cpp: In function 'void sub2::sol()':
Main.cpp:66:62: error: no matching function for call to 'min(int&, long long int)'
   66 |                 for(int j=i + d[i]; j<=min(n, i + x[i] * d[i]); j+=d[i])
      |                                                              ^
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:4:
/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:66:62: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   66 |                 for(int j=i + d[i]; j<=min(n, i + x[i] * d[i]); j+=d[i])
      |                                                              ^
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:4:
/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:66:62: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   66 |                 for(int j=i + d[i]; j<=min(n, i + x[i] * d[i]); j+=d[i])
      |                                                              ^
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:4:
/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:66:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   66 |                 for(int j=i + d[i]; j<=min(n, i + x[i] * d[i]); j+=d[i])
      |                                                              ^
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:4:
/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:66:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   66 |                 for(int j=i + d[i]; j<=min(n, i + x[i] * d[i]); j+=d[i])
      |                                                              ^