Submission #1136001

#TimeUsernameProblemLanguageResultExecution timeMemory
1136001ThanhsSum Zero (RMI20_sumzero)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define name "TENBAI" #define fi first #define se second #define int long long #define endl '\n' #define setmin(x, y) x = min((x), (y)) #define setmax(x, y) x = max((x), (y)) #define sqr(x) ((x) * (x)) mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count()); int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);} const int NM = 4e5 + 5; vector<int> nen; vector<pair<int32_t, int32_t>> v; int A[NM]; int32_t n, a[NM][19], pr[NM]; void solve() { memset(pr, -1, sizeof pr); cin >> n; nen.push_back(0); for (int i = 1; i <= n; i++) { cin >> A[i]; A[i] += A[i - 1]; nen.push_back(A[i]); } sort(nen.begin(), nen.end()); nen.erase(unique(nen.begin(), nen.end())); for (int i = 0; i <= n; i++) { A[i] = lower_bound(nen.begin(), nen.end(), A[i]) - nen.begin(); if (~pr[A[i]]) v.emplace_back(pr[A[i]] + 1, i); pr[A[i]] = i; } sort(v.begin(), v.end(), [&](const auto& x, const auto& y) {return x.fi > y.fi;}); int pt = 0, mn = n + 1; for (int i = n; i >= 1; i--) { while (pt < v.size() && v[pt].fi >= i) setmin(mn, v[pt++].se); a[i][0] = mn; } a[n + 1][0] = n + 1; for (int i = 1; (1 << i) <= n; i++) for (int j = 1; j <= n + 1; j++) { if (a[j][i - 1] == n + 1) a[j][i] = n + 1; else a[j][i] = (a[a[j][i - 1] + 1][i - 1]); } int q; cin >> q; while (q--) { int l, r; cin >> l >> r; int ans = 0; for (int i = __lg(n); i >= 0; i--) if (a[l][i] <= r) { ans += 1 << i; l = a[l][i] + 1; } cout << ans << endl; } } signed main() { if (fopen("in.txt", "r")) { freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); } else if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int tc = 1; // cin >> tc; while (tc--) solve(); }

Compilation message (stderr)

sumzero.cpp: In function 'void solve()':
sumzero.cpp:9:29: error: no matching function for call to 'min(long long int&, int&)'
    9 | #define setmin(x, y) x = min((x), (y))
      |                          ~~~^~~~~~~~~~
sumzero.cpp:48:13: note: in expansion of macro 'setmin'
   48 |             setmin(mn, v[pt++].se);
      |             ^~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from sumzero.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
sumzero.cpp:9:29: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    9 | #define setmin(x, y) x = min((x), (y))
      |                          ~~~^~~~~~~~~~
sumzero.cpp:48:13: note: in expansion of macro 'setmin'
   48 |             setmin(mn, v[pt++].se);
      |             ^~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from sumzero.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
sumzero.cpp:9:29: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    9 | #define setmin(x, y) x = min((x), (y))
      |                          ~~~^~~~~~~~~~
sumzero.cpp:48:13: note: in expansion of macro 'setmin'
   48 |             setmin(mn, v[pt++].se);
      |             ^~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from sumzero.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
sumzero.cpp:9:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    9 | #define setmin(x, y) x = min((x), (y))
      |                          ~~~^~~~~~~~~~
sumzero.cpp:48:13: note: in expansion of macro 'setmin'
   48 |             setmin(mn, v[pt++].se);
      |             ^~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from sumzero.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
sumzero.cpp:9:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    9 | #define setmin(x, y) x = min((x), (y))
      |                          ~~~^~~~~~~~~~
sumzero.cpp:48:13: note: in expansion of macro 'setmin'
   48 |             setmin(mn, v[pt++].se);
      |             ^~~~~~
sumzero.cpp: In function 'int main()':
sumzero.cpp:81:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   81 |         freopen("in.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
sumzero.cpp:82:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |         freopen("out.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sumzero.cpp:86:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sumzero.cpp:87:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   87 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~