经常有点小迷糊 2022-01-21 20:57 采纳率: 96.7%
浏览 679
已结题

洛谷提交之后,不知道是啥错误,编译错误,这咋改


/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;
} 

  • 写回答

3条回答 默认 最新

  • [PE]经典八炮 2022-01-21 21:06
    关注

    哈,拜你用万能头和using namespace所赐,这是非常不好的代码风格

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 1月29日
  • 已采纳回答 1月21日
  • 创建了问题 1月21日

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?