Submission #225261

#TimeUsernameProblemLanguageResultExecution timeMemory
225261bukanYohandiSolar Storm (NOI20_solarstorm)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> /* Karya anak bangsa yang paling agung Author : Yohandi or... bukan.. */ #define fs first #define sc second #define pb push_back #define eb emplace_back #define all(a) a.begin(),a.end() #define lb(a,x) (lower_bound(all(a),x)-a.begin()) #define ub(a,x) (upper_bound(all(a),x)-a.begin()) #define rep(a,x,y) for(int a=(int)x;a<=(int)y;++a) #define repd(a,x,y,d) for(int a=(int)x;a<=(int)y;a+=d) #define res(a,x,y) for(int a=(int)x;a>=(int)y;--a) #define resd(a,x,y,d) for(int a=(int)x;a>=(int)y;a-=d) // Ordered Set, Ordered Multiset #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> #define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> using namespace __gnu_pbds; // .order_of_key(x) -> Number of elements less than x // * .find_by_order(k) -> Kth smallest element (0-based) // .erase(x) -> Remove all elements equal to x #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; using lint=long long; mt19937 rng(time(NULL)); lint Power(lint A,lint B,lint C){ if(!B) return 1LL; lint tmp=Power(A,B>>1,C); return tmp*tmp%C*(B&1?A:1)%C; } int T,N,S,Le,Ri,Id,Log; int Par[1111111][21]; lint K,Ans,Sum; lint V[1111111],D[1111111]; pair<int,int> P[1111111]; int Ancestor(int U,int Diff){ for(int j=Log;j>=0;--j){ if(Diff&(1<<j)) U=Par[U][j]; } return U; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); T=1; // cin>>T; rep(t,1,T){ cin>>N>>S>>K; Log=log2(N+1) for(int i=1;i<=N-1;++i){ cin>>D[i]; D[i]+=D[i-1]; } for(int i=1;i<=N;++i){ cin>>V[i]; V[i]+=V[i-1]; } Le=1; Ri=1; for(int i=1;i<=N;++i){ while(Le<=i&&D[i-1]-D[Le-1]>K) Le++; while(Ri<=N&&D[Ri-1]-D[i-1]<=K) Ri++; P[Le].fs=Ri; P[Le].sc=i; } P[N+1]=N+1; memset(Par,-1,sizeof(Par)); for(int i=1;i<=N+1;++i) Par[i][0]=P[i].fs; for(int j=1;j<=Log;++j) for(int i=1;i<=N+1;++i) if(Par[i][j-1]!=-1&&Par[Par[i][j-1]][j-1]!=-1) Par[i][j]=Par[Par[i][j-1]][j-1]; for(int i=1;i<=N;++i){ Sum=V[Ancestor(i,S)-1]-V[i-1]; if(Ans<Sum){ Ans=Sum; Id=i; } } cout<<S<<endl; for(int i=1;i<=S;++i){ if(i!=1) cout<<" "; cout<<P[Id].sc; Id=P[Id].fs; } cout<<"\n"; } return 0; }

Compilation message (stderr)

SolarStorm.cpp: In function 'int main()':
SolarStorm.cpp:68:9: error: expected ';' before 'for'
         for(int i=1;i<=N-1;++i){
         ^~~
SolarStorm.cpp:68:21: error: 'i' was not declared in this scope
         for(int i=1;i<=N-1;++i){
                     ^
SolarStorm.cpp:83:18: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and 'int')
         P[N+1]=N+1;
                  ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from SolarStorm.cpp:1:
/usr/include/c++/7/bits/stl_pair.h:367:7: note: candidate: std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_copy_assignable<_Tp>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch_no_braces&>::type) [with _T1 = int; _T2 = int; typename std::conditional<std::__and_<std::is_copy_assignable<_Tp>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch_no_braces&>::type = const std::pair<int, int>&]
       operator=(typename conditional<
       ^~~~~~~~
/usr/include/c++/7/bits/stl_pair.h:367:7: note:   no known conversion for argument 1 from 'int' to 'std::conditional<true, const std::pair<int, int>&, const std::__nonesuch_no_braces&>::type {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_pair.h:384:7: note: candidate: std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch_no_braces&&>::type) [with _T1 = int; _T2 = int; typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch_no_braces&&>::type = std::pair<int, int>&&]
       operator=(typename conditional<
       ^~~~~~~~
/usr/include/c++/7/bits/stl_pair.h:384:7: note:   no known conversion for argument 1 from 'int' to 'std::conditional<true, std::pair<int, int>&&, std::__nonesuch_no_braces&&>::type {aka std::pair<int, int>&&}'
/usr/include/c++/7/bits/stl_pair.h:400:2: note: candidate: template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = int]
  operator=(const pair<_U1, _U2>& __p)
  ^~~~~~~~
/usr/include/c++/7/bits/stl_pair.h:400:2: note:   template argument deduction/substitution failed:
SolarStorm.cpp:83:18: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
         P[N+1]=N+1;
                  ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from SolarStorm.cpp:1:
/usr/include/c++/7/bits/stl_pair.h:411:2: note: candidate: template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = int]
  operator=(pair<_U1, _U2>&& __p)
  ^~~~~~~~
/usr/include/c++/7/bits/stl_pair.h:411:2: note:   template argument deduction/substitution failed:
SolarStorm.cpp:83:18: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
         P[N+1]=N+1;
                  ^