/tmp/compiler_yu0_ximz/src: 在函数‘int main()’中:
/tmp/compiler_yu0_ximz/src:27:50: 错误:对‘data’的引用有歧义
27 | for (int j = h[xx]; j != -1; j = data[j].next) {
| ^~~~
In file included from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/string:54,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/locale_classes.h:40,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/ios_base.h:41,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/ios:42,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/istream:38,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/sstream:38,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/complex:45,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/ccomplex:39,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/x86_64-unknown-linux-gnu/bits/stdc++.h:54,
from /tmp/compiler_yu0_ximz/src:1:
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:319:5: 附注:备选为: ‘template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)’
319 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:310:5: 附注: ‘template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])’
310 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:300:5: 附注: ‘template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)’
300 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:290:5: 附注: ‘template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)’
290 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/tmp/compiler_yu0_ximz/src:10:6: 附注: ‘node data [110000]’
10 | node data[N];
| ^~~~
/tmp/compiler_yu0_ximz/src:28:29: 错误:对‘data’的引用有歧义
28 | if (data[j].x == a[i]) {
| ^~~~
In file included from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/string:54,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/locale_classes.h:40,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/ios_base.h:41,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/ios:42,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/istream:38,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/sstream:38,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/complex:45,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/ccomplex:39,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/x86_64-unknown-linux-gnu/bits/stdc++.h:54,
from /tmp/compiler_yu0_ximz/src:1:
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:319:5: 附注:备选为: ‘template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)’
319 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:310:5: 附注: ‘template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])’
310 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:300:5: 附注: ‘template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)’
300 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:290:5: 附注: ‘template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)’
290 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/tmp/compiler_yu0_ximz/src:10:6: 附注: ‘node data [110000]’
10 | node data[N];
| ^~~~
/tmp/compiler_yu0_ximz/src:29:40: 错误:对‘data’的引用有歧义
29 | ans += data[j].s;
| ^~~~
In file included from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/string:54,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/locale_classes.h:40,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/ios_base.h:41,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/ios:42,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/istream:38,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/sstream:38,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/complex:45,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/ccomplex:39,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/x86_64-unknown-linux-gnu/bits/stdc++.h:54,
from /tmp/compiler_yu0_ximz/src:1:
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:319:5: 附注:备选为: ‘template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)’
319 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:310:5: 附注: ‘template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])’
310 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:300:5: 附注: ‘template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)’
300 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:290:5: 附注: ‘template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)’
290 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/tmp/compiler_yu0_ximz/src:10:6: 附注: ‘node data [110000]’
10 | node data[N];
| ^~~~
/tmp/compiler_yu0_ximz/src:30:33: 错误:对‘data’的引用有歧义
30 | data[j].s++;
| ^~~~
In file included from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/string:54,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/locale_classes.h:40,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/ios_base.h:41,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/ios:42,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/istream:38,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/sstream:38,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/complex:45,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/ccomplex:39,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/x86_64-unknown-linux-gnu/bits/stdc++.h:54,
from /tmp/compiler_yu0_ximz/src:1:
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:319:5: 附注:备选为: ‘template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)’
319 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:310:5: 附注: ‘template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])’
310 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:300:5: 附注: ‘template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)’
300 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/range_access.h:290:5: 附注: ‘template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)’
290 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/tmp/compiler_yu0_ximz/src:10:6: 附注: ‘node data [110000]’
10 | node data[N];
| ^~~~
/tmp/compiler_yu0_ximz/src:37:25: 错误:对‘data’的引用有歧义
37 |
...
代码
#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
const int P = 122033;
int a[N], b[N];
struct node {
int x, s;
int next;
};
node data[N];
int h[P];
int num, n, m;
bool f1;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i)
scanf("%d", b + i);
b[0] = 0;
for (int i = 1; i <= n; ++i)
a[i] = (a[i - 1] + b[i]) % m;
long long ans = 0;
memset(h, -1, sizeof h);
num = 0;
for (int i = 0; i <= n; ++i) {
f1 = false;
int xx = a[i] % P;
for (int j = h[xx]; j != -1; j = data[j].next) {
if (data[j].x == a[i]) {
ans += data[j].s;
data[j].s++;
f1 = true;
break;
}
}
if (!f1){
++num;
data[num].x = a[i];
data[num].s = 1;
data[num].next = h[xx];
h[xx] = num;
}
}
printf("%lld", ans);
return 0;
}