# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
825524 | boyliguanhan | Election (BOI18_election) | C++17 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
struct data {
int l=0,r=0,s=0,a=0;
data(bool b) : l(b), r(b), s(b?1:-1), a(b){}
data(data a, data b) : l(max(a.l, a.s+b.l)), r(max(b.r,b.s+a.r)), s(a.s+b.s), a(max(max(a.a+b.s, b.a+a.s), a.l+b.r)){}
};
vector<vector<data>> tb(500100, vector<data>(20));
int main() {
int n, q;
string str;
cin >> n >> str >> q;
for(int i = 1; i <= n; i++) {
tb[i][0] = data(str[i-1]=='T');
}
for(int j = 1; j < 20; j++)
for(int i = 1; i < n-(1<<j)+2; i++)
tb[i][j] = data(tb[i][j-1], tb[i+(1<<j-1)][j-1]);
while(q--){
data d;
int a, b;
cin >> a >> b;
for(int i = 20;i--;)
if(a+(1<<i)-2<b)
d = data(d,tb[a][i]), a+=(1<<i);
cout << d.a << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
election.cpp:8:15: error: template argument 1 is invalid 8 | vector<vector<data>> tb(500100, vector<data>(20)); | ^~~~ election.cpp:8:15: error: template argument 2 is invalid election.cpp:8:19: error: template argument 1 is invalid 8 | vector<vector<data>> tb(500100, vector<data>(20)); | ^~ election.cpp:8:19: error: template argument 2 is invalid election.cpp:8:44: error: template argument 1 is invalid 8 | vector<vector<data>> tb(500100, vector<data>(20)); | ^ election.cpp:8:44: error: template argument 2 is invalid election.cpp:8:49: error: expression list treated as compound expression in initializer [-fpermissive] 8 | vector<vector<data>> tb(500100, vector<data>(20)); | ^ election.cpp: In function 'int main()': election.cpp:14:11: error: invalid types 'int[int]' for array subscript 14 | tb[i][0] = data(str[i-1]=='T'); | ^ election.cpp:14:20: error: reference to 'data' is ambiguous 14 | tb[i][0] = data(str[i-1]=='T'); | ^~~~ In file included from /usr/include/c++/10/string:54, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from election.cpp:1: /usr/include/c++/10/bits/range_access.h:319:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)' 319 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/10/bits/range_access.h:310:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 310 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/10/bits/range_access.h:300:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 300 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/10/bits/range_access.h:290:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 290 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ election.cpp:3:8: note: 'struct data' 3 | struct data { | ^~~~ election.cpp:18:15: error: invalid types 'int[int]' for array subscript 18 | tb[i][j] = data(tb[i][j-1], tb[i+(1<<j-1)][j-1]); | ^ election.cpp:18:24: error: reference to 'data' is ambiguous 18 | tb[i][j] = data(tb[i][j-1], tb[i+(1<<j-1)][j-1]); | ^~~~ In file included from /usr/include/c++/10/string:54, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from election.cpp:1: /usr/include/c++/10/bits/range_access.h:319:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)' 319 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/10/bits/range_access.h:310:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 310 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/10/bits/range_access.h:300:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 300 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/10/bits/range_access.h:290:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 290 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ election.cpp:3:8: note: 'struct data' 3 | struct data { | ^~~~ election.cpp:18:31: error: invalid types 'int[int]' for array subscript 18 | tb[i][j] = data(tb[i][j-1], tb[i+(1<<j-1)][j-1]); | ^ election.cpp:18:51: warning: suggest parentheses around '-' inside '<<' [-Wparentheses] 18 | tb[i][j] = data(tb[i][j-1], tb[i+(1<<j-1)][j-1]); | ~^~ election.cpp:18:43: error: invalid types 'int[int]' for array subscript 18 | tb[i][j] = data(tb[i][j-1], tb[i+(1<<j-1)][j-1]); | ^ election.cpp:20:9: error: reference to 'data' is ambiguous 20 | data d; | ^~~~ In file included from /usr/include/c++/10/string:54, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from election.cpp:1: /usr/include/c++/10/bits/range_access.h:319:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)' 319 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/10/bits/range_access.h:310:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 310 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/10/bits/range_access.h:300:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 300 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/10/bits/range_access.h:290:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 290 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ election.cpp:3:8: note: 'struct data' 3 | struct data { | ^~~~ election.cpp:25:17: error: 'd' was not declared in this scope 25 | d = data(d,tb[a][i]), a+=(1<<i); | ^ election.cpp:25:21: error: reference to 'data' is ambiguous 25 | d = data(d,tb[a][i]), a+=(1<<i); | ^~~~ In file included from /usr/include/c++/10/string:54, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from election.cpp:1: /usr/include/c++/10/bits/range_access.h:319:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)' 319 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/10/bits/range_access.h:310:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 310 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/10/bits/range_access.h:300:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 300 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/10/bits/range_access.h:290:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 290 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ election.cpp:3:8: note: 'struct data' 3 | struct data { | ^~~~ election.cpp:25:30: error: invalid types 'int[int]' for array subscript 25 | d = data(d,tb[a][i]), a+=(1<<i); | ^ election.cpp:26:17: error: 'd' was not declared in this scope 26 | cout << d.a << '\n'; | ^