Submission #1219619

#TimeUsernameProblemLanguageResultExecution timeMemory
1219619khomeXORanges (eJOI19_xoranges)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define int long long // const int INF = 1e18; const int NEU = 0; int rec(int l, int r, vector<vector<int>> &v){ int ans = 0; for (int j = 0; j < 32; j++){ int cur = v[r][31-j] - v[l-1][31-j]; cur %= 2; ans += cur * (1<<j); } return ans; } void add(vector<vector<int>> &v, int id, int x){ for (int i = 0; i <= 31; i++){ v[id][31-i] = min(1ll, x & (1<<i)) + v[id-1][31-i]; } return; } void solve(){ int n, q; cin >> n >> q; vector<vector<int>> toq((n+1)/2+1, vector<int>(32)); vector<vector<int>> juft(n/2+1, vector<int>(32)); for (int i = 0 ; i < n; i++) { int x; cin >> x; if (i%2==0) add(toq, i/2+1, x); if (i%2==1) add(juft, i/2+1, x); } for (int i = 0; i < q; i++) { int p, l, r; cin >> p >> l >> r; if (p == 1) { if (l%2 == 1) { for (int j = (l-1)/2 + 2; j < (n+1)/2+1; j++){ for (int w = 0; w <= 31; w++){ toq[j][31-w] += min(1ll, r & (1<<w)) - toq[(l-1)/2+1][31-w]; } } add(toq, (l-1)/2+1, r); for (auto i : toq){ for (int j : i) cerr << j; cerr << endl; }cerr << endl; } else { for (int j = (l-1)/2 + 2; j < n/2+1; j++){ for (int w = 0; w <= 31; w++){ juft[j][31-w] += min(1, r & (1<<w)) - juft[(l-1)/2+1][31-w]; } } add(juft, (l-1)/2+1, r); for (auto i : juft){ for (int j : i) cerr << j; cerr << endl; }cerr << endl; } } else { if ((r-l+1) % 2 == 0) cout << 0 << endl; else{ if (l%2 == 1) { cout << rec((l-1)/2+1, (r-1)/2+1, toq); } if (l%2 == 0) { cout << rec((l-1)/2+1, (r-1)/2+1, juft); } } cout << endl; } } } signed main(){ ios::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; while(t--)solve(); }

Compilation message (stderr)

xoranges.cpp: In function 'void solve()':
xoranges.cpp:58:45: error: no matching function for call to 'min(int, long long int)'
   58 |                         juft[j][31-w] += min(1, r & (1<<w)) - juft[(l-1)/2+1][31-w];
      |                                          ~~~^~~~~~~~~~~~~~~
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 xoranges.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:
xoranges.cpp:58:45: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   58 |                         juft[j][31-w] += min(1, r & (1<<w)) - juft[(l-1)/2+1][31-w];
      |                                          ~~~^~~~~~~~~~~~~~~
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 xoranges.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:
xoranges.cpp:58:45: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   58 |                         juft[j][31-w] += min(1, r & (1<<w)) - juft[(l-1)/2+1][31-w];
      |                                          ~~~^~~~~~~~~~~~~~~
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 xoranges.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:
xoranges.cpp:58:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   58 |                         juft[j][31-w] += min(1, r & (1<<w)) - juft[(l-1)/2+1][31-w];
      |                                          ~~~^~~~~~~~~~~~~~~
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 xoranges.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:
xoranges.cpp:58:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   58 |                         juft[j][31-w] += min(1, r & (1<<w)) - juft[(l-1)/2+1][31-w];
      |                                          ~~~^~~~~~~~~~~~~~~