제출 #467959

#제출 시각아이디문제언어결과실행 시간메모리
467959MilosMilutinovicSum Zero (RMI20_sumzero)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N=400005; const int L=10; int st[L][N]; vector<ll> xs; void Add(int x){xs.push_back(xs);} void Build(int n){ for(int i=0;i<N;i++){ for(int j=0;j<L;j++)st[j][i]=N-2; } ll sum=0; was[0]=0; int x; for(int i=1;i<=n;i++){ scanf("%i",&x); sum+=x; if(was.count(sum)){ st[0][was[sum]+1]=i; } was[sum]=i; } int mn=N-1; for(int i=n;i>=1;i--)st[0][i]=min(st[0][i+1],st[0][i]); for(int i=1;i<L;i++){ for(int j=1;j<=n;j++){ st[i][j]=st[i-1][st[i-1][j]+1]; } } } int main(){ int n;scanf("%i",&n); Build(n); int q;scanf("%i",&q); int l,r,ans=0; while(q--){ scanf("%i%i",&l,&r); ans=0; for(int i=L-1;i>=0;i--){ if(st[i][l]<=r)ans+=(1<<i),l=st[i][l]+1; } printf("%i\n",ans); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

sumzero.cpp: In function 'void Add(int)':
sumzero.cpp:8:32: error: no matching function for call to 'std::vector<long long int>::push_back(std::vector<long long int>&)'
    8 | void Add(int x){xs.push_back(xs);}
      |                                ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from sumzero.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const value_type&' {aka 'const long long int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<long long int>::value_type&&' {aka 'long long int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
sumzero.cpp: In function 'void Build(int)':
sumzero.cpp:15:5: error: 'was' was not declared in this scope
   15 |     was[0]=0;
      |     ^~~
sumzero.cpp:25:9: warning: unused variable 'mn' [-Wunused-variable]
   25 |     int mn=N-1;
      |         ^~
sumzero.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%i",&x);
      |         ~~~~~^~~~~~~~~
sumzero.cpp: In function 'int main()':
sumzero.cpp:34:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     int n;scanf("%i",&n);
      |           ~~~~~^~~~~~~~~
sumzero.cpp:36:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     int q;scanf("%i",&q);
      |           ~~~~~^~~~~~~~~
sumzero.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |         scanf("%i%i",&l,&r);
      |         ~~~~~^~~~~~~~~~~~~~