제출 #548787

#제출 시각아이디문제언어결과실행 시간메모리
548787ala2가로등 (APIO19_street_lamps)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back using namespace std; //int a[1001000]; string s; int n,T; vector<pair<int,int>>anss; vector<int>v[100100]; vector<int>von[100100]; vector<int>vtype[101000]; int bit(int i) { return s[i]=='1'&&s[i+1]=='1'; } char f(char x) { if(x=='1') { return '0'; } else return '1'; } signed main() { cin>>n>>T; cin>>s; // A 1 B 2 s+='1'; for(int i=0;i<n;i++) { v[i].pb(0); vtype[i].pb(1); if(s[i]=='1'&&s[i+1]=='1') { von[i].pb(1); } else von[i].pb(0); } for(int q=1;q<=T;q++) { string c; cin>>c; if(c[0]=='q') c='B'; else c='A'; if(c=="A") { int i; cin>>i; i--; int old=bit(i); s[i]=f(s[i]); int nw=bit(i); v[i].pb(q); vtype[i].pb(1); /* if(nw>old) { von[i].pb(1); } else if(old>nw) von[i].pb(0); else { int x=von[i].size(); von[i].pb(von[i][x-1]); } */ von[i]=nw; continue; } int a,b; cin>>a>>b; a--; b--; int i=a; v[i].pb(q); int x=von[i].size(); von[i].pb(von[i][x-1]); vtype[i].pb(2); } for(int i=0;i<=n;i++) { int g=0; for(int j=1;j<v[i].size();j++) { // cout<<" "<<i<<endl; if(von[i][j-1]==1&&von[i][j]) g+=v[i][j]-v[i][j-1]; if(vtype[i][j]==2) { int x=g; anss.pb({v[i][j],x}); } } } sort(anss.begin(),anss.end()); for(auto i:anss) { cout<<i.second<<endl; } } // 2 6 11 q 1 2 t 1 q 1 2 q 1 2 t 1 q 1 2

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

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:68:20: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'long long int')
   68 |             von[i]=nw;
      |                    ^~
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from street_lamps.cpp:1:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'long long int' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
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 street_lamps.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'long long int' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'long long int' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
street_lamps.cpp:52:17: warning: unused variable 'old' [-Wunused-variable]
   52 |             int old=bit(i);
      |                 ^~~
street_lamps.cpp:85:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |         for(int j=1;j<v[i].size();j++)
      |                     ~^~~~~~~~~~~~