Submission #1118631

#TimeUsernameProblemLanguageResultExecution timeMemory
1118631peraSum Zero (RMI20_sumzero)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define LL long long using namespace std; const int N = 4e5 + 1; int a[N] , l[N] , r[N] , ans[N]; vector<int> lst(N) , e; int main(){ cin.tie(0)->sync_with_stdio(0); int n; cin >> n; for(int i = 1;i <= n;i ++){ cin >> a[i]; } LL sum = 0; map<LL , int> e; e[0] = 0; lst[0] = -1; for(int i = 1;i <= n;i ++){ sum += a[i]; if(e.find(sum) != e.end()){ lst[i] = e[sum]; }else{ lst[i] = -1; } lst[i] = max(lst[i] , lst[i - 1]); e[sum] = i; } int q; cin >> q; memset(ans , 0 , sizeof(ans)); for(int i = 0;i < q;i ++){ cin >> l[i] >> r[i]; } for(int bit = 18;bit >= 0;bit --){ e = lst; for(int c = 0;c < bit;c ++){ for(int i = n;i >= 0;i --){ e[i] = (e[i] > -1 ? e[e[i]] : -1); } } for(int i = 0;i < q;i ++){ if(e[r[i]] >= l[i] - 1){ ans[i] += 1 << bit; r[i] = e[r[i]]; } } } for(int i = 0;i < q;i ++){ cout << ans[i] << '\n'; } }

Compilation message (stderr)

sumzero.cpp: In function 'int main()':
sumzero.cpp:35:11: error: no match for 'operator=' (operand types are 'std::map<long long int, int>' and 'std::vector<int>')
   35 |       e = lst;
      |           ^~~
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from sumzero.cpp:1:
/usr/include/c++/10/bits/stl_map.h:319:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(const std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = long long int; _Tp = int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, int> >]'
  319 |       operator=(const map&) = default;
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:319:17: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::map<long long int, int>&'
  319 |       operator=(const map&) = default;
      |                 ^~~~~~~~~~
/usr/include/c++/10/bits/stl_map.h:323:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(std::map<_Key, _Tp, _Compare, _Alloc>&&) [with _Key = long long int; _Tp = int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, int> >]'
  323 |       operator=(map&&) = default;
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:323:17: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::map<long long int, int>&&'
  323 |       operator=(map&&) = default;
      |                 ^~~~~
/usr/include/c++/10/bits/stl_map.h:337:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(std::initializer_list<std::pair<const _Key, _Tp> >) [with _Key = long long int; _Tp = int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, int> >]'
  337 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:337:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<std::pair<const long long int, int> >'
  337 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~