# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
775244 | burythelightdeepwithin | Addk (eJOI21_addk) | C++14 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll maxn=200005;
ll n,m,k;
ll a[maxn];
ll tree[4*maxn];
void make_tree(ll pos, ll low, ll high)
{
if(low==high)
{
tree[pos]=a[low];
return;
}
ll mid=(low+high)/2;
make_tree(2*pos+1,low,mid);
make_tree(2*pos+2,mid+1,high);
tree[pos]=(tree[2*pos+1]+tree[2*pos+2]);
}
void update(ll pos, ll low, ll high, ll query, ll up)
{
if (query>high || query<low)
{
return;
}
if (low==high)
{
tree[pos]=up;
return;
}
ll mid=(low+high)/2;
update(2*pos+1,low,mid,query,up);
update(2*pos+2,mid+1,high,query,up);
tree[pos]=tree[2*pos+1]+tree[2*pos+2];
}
ll SumQuery(ll pos, ll low, ll high, ll qlow, ll qhigh)
{
if (qlow>high || qhigh<low)
{
return 0;
}
if (qlow<=low && high<=qhigh)
{
return tree[pos];
}
ll mid=(low+high)/2;
return SumQuery(2*pos+1,low,mid,qlow,qhigh)+SumQuery(2*pos+2,mid+1,high,qlow,qhigh);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> k;
for (ll i=0; i<n; i++)
{
cin >> a[i];
}
make_tree(0,0,n-1);
cin >> m;
while (m--)
{
ll t;
cin >> t;
if (t==1)
{
vector<ll>v;
for (ll j=1; j<=k; j++)
{
ll x;
cin >> x;
x--;
v.push_back(x);
}
ll cur=a[v[0]];
for (ll i=1; i<v.size(); i++)
{
a[v[i-1]]=a[v[i]];
}
a[v[v.size()-1]]=cur;
for (auto it:v)
{
update(0,0,n-1,it,a[it]);
}
// for (ll i=0; i<n; i++) {
// cout << a[i] << " ";
// }
// cout << endl;
} else {
ll l,r,m;
cin >> l >> r >> m;
l--;
r--;
ll ans=get(0,0,n-1,l,r);
ll ptr1=x, ptr2=y;
ll sum = 0;
ll cnt = 0;
while (ptr1<=ptr2 && ptr2>=l+m-1 && cnt<m)
{
sum+=ans;
ans-=(a[ptr1]+a[ptr2]);
ptr2--; ptr1++;
cnt++;
}
cout << sum << endl;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()': Main.cpp:82:27: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 82 | for (ll i=1; i<v.size(); i++) | ~^~~~~~~~~ Main.cpp:100:26: error: no matching function for call to 'get(int, int, ll, ll&, ll&)' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/utility:223:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)' 223 | get(std::pair<_Tp1, _Tp2>& __in) noexcept | ^~~ /usr/include/c++/10/utility:223:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'std::pair<_Tp1, _Tp2>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/utility:228:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)' 228 | get(std::pair<_Tp1, _Tp2>&& __in) noexcept | ^~~ /usr/include/c++/10/utility:228:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'std::pair<_Tp1, _Tp2>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/utility:233:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)' 233 | get(const std::pair<_Tp1, _Tp2>& __in) noexcept | ^~~ /usr/include/c++/10/utility:233:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/utility:238:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const std::pair<_Tp1, _Tp2>&&)' 238 | get(const std::pair<_Tp1, _Tp2>&& __in) noexcept | ^~~ /usr/include/c++/10/utility:238:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/utility:247:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)' 247 | get(pair<_Tp, _Up>& __p) noexcept | ^~~ /usr/include/c++/10/utility:247:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'std::pair<_T1, _T2>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/utility:252:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)' 252 | get(const pair<_Tp, _Up>& __p) noexcept | ^~~ /usr/include/c++/10/utility:252:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'const std::pair<_T1, _T2>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/utility:257:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)' 257 | get(pair<_Tp, _Up>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:257:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'std::pair<_T1, _T2>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/utility:262:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_T1, _T2>&&)' 262 | get(const pair<_Tp, _Up>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:262:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'const std::pair<_T1, _T2>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/utility:267:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)' 267 | get(pair<_Up, _Tp>& __p) noexcept | ^~~ /usr/include/c++/10/utility:267:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'std::pair<_Up, _Tp>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/utility:272:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)' 272 | get(const pair<_Up, _Tp>& __p) noexcept | ^~~ /usr/include/c++/10/utility:272:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'const std::pair<_Up, _Tp>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/utility:277:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)' 277 | get(pair<_Up, _Tp>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:277:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'std::pair<_Up, _Tp>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/utility:282:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_Up, _Tp>&&)' 282 | get(const pair<_Up, _Tp>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:282:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'const std::pair<_Up, _Tp>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from Main.cpp:1: /usr/include/c++/10/array:334:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(std::array<_Tp, _Nm>&)' 334 | get(array<_Tp, _Nm>& __arr) noexcept | ^~~ /usr/include/c++/10/array:334:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'std::array<_Tp, _Nm>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from Main.cpp:1: /usr/include/c++/10/array:343:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(std::array<_Tp, _Nm>&&)' 343 | get(array<_Tp, _Nm>&& __arr) noexcept | ^~~ /usr/include/c++/10/array:343:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'std::array<_Tp, _Nm>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from Main.cpp:1: /usr/include/c++/10/array:351:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const std::array<_Tp, _Nm>&)' 351 | get(const array<_Tp, _Nm>& __arr) noexcept | ^~~ /usr/include/c++/10/array:351:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'const std::array<_Tp, _Nm>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from Main.cpp:1: /usr/include/c++/10/array:360:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const std::array<_Tp, _Nm>&&)' 360 | get(const array<_Tp, _Nm>&& __arr) noexcept | ^~~ /usr/include/c++/10/array:360:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'const std::array<_Tp, _Nm>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from Main.cpp:1: /usr/include/c++/10/tuple:1294:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(std::tuple<_Elements ...>&)' 1294 | get(tuple<_Elements...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1294:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'std::tuple<_Elements ...>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from Main.cpp:1: /usr/include/c++/10/tuple:1300:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const std::tuple<_Elements ...>&)' 1300 | get(const tuple<_Elements...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1300:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'const std::tuple<_Elements ...>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from Main.cpp:1: /usr/include/c++/10/tuple:1306:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(std::tuple<_Elements ...>&&)' 1306 | get(tuple<_Elements...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1306:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'std::tuple<_Elements ...>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from Main.cpp:1: /usr/include/c++/10/tuple:1315:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const std::tuple<_Elements ...>&&)' 1315 | get(const tuple<_Elements...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1315:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'const std::tuple<_Elements ...>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from Main.cpp:1: /usr/include/c++/10/tuple:1338:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_Elements ...>&)' 1338 | get(tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1338:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'std::tuple<_Elements ...>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from Main.cpp:1: /usr/include/c++/10/tuple:1344:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_Elements ...>&&)' 1344 | get(tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1344:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'std::tuple<_Elements ...>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from Main.cpp:1: /usr/include/c++/10/tuple:1350:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::tuple<_Elements ...>&)' 1350 | get(const tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1350:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'const std::tuple<_Elements ...>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ In file included from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from Main.cpp:1: /usr/include/c++/10/tuple:1357:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::tuple<_Elements ...>&&)' 1357 | get(const tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1357:5: note: template argument deduction/substitution failed: Main.cpp:100:26: note: mismatched types 'const std::tuple<_Elements ...>' and 'int' 100 | ll ans=get(0,0,n-1,l,r); | ^ Main.cpp:101:12: error: 'x' was not declared in this scope 101 | ll ptr1=x, ptr2=y; | ^ Main.cpp:104:17: error: 'ptr2' was not declared in this scope; did you mean 'ptr1'? 104 | while (ptr1<=ptr2 && ptr2>=l+m-1 && cnt<m) | ^~~~ | ptr1