제출 #937401

#제출 시각아이디문제언어결과실행 시간메모리
937401LibAliens (IOI16_aliens)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "aliens.h" //Aliens - CHT variant using namespace std; //long long DP[6000][6000]; //dp[i][k]: Minimum cost for covering the first i segments with EXACTLY k pictures (obviously i>=k) vector <vector <long long> > DP; long long N,M; //Why tf are there segments here? Refer to the official editorial for that - the expaination seems good enough const long long INF=2000000000000000000; struct seg{ long long Start; long long End; }; seg Segments[200003]; vector <seg> ActualSegments; //Custom sort function for removing uneeded segments. If a segment which starts at L and end at R is kept, alongside with another segment which starts at L' and end as R', and L'<= L <= R <= R' (aka: The segment is completely covered), the DP will become absolute shitfuckery and extremely wrong (trust me, I thought it would work but it didn't) bool operator< (const seg &x, const seg &y){ if(x.Start==y.Start){ return x.End>y.End; }else{ return x.Start<y.Start; } } //Binpow template for non-shitty squaring long long binpow(long long x, long long pow){ if(pow==1){ return x; } if(pow==0){ return 1; } return binpow(x,pow/2)*binpow(x,(pow+1)/2); } //Define lines type struct Lines{ //form: y=ax+b, where x will eventually be the endpoint coordinate of a segment long long Slopes; //a long long Extras; //b } vector <Lines> CurrentConvexHull; void CalcDP(int k){ CurrentConvexHull.clear(); } long long take_photos(int n,int m, int Pics, vector <int> Rows, vector <int> Columns){ for(int i=1;i<=N;i++){ Segments[i]={min(Rows[i-1],Columns[i-1])+1,max(Rows[i-1],Columns[i-1])+1}; } sort(Segments+1,Segments+N+1); ActualSegments.push_back({0,0}); //Removing the fully-covered segments: It is easy to see that our resulting set of segments will have the later segments have both higher start and endpoints when compared to all previous ones, so...... Again, if you can't understand this, you shouldn't try learning about fucking ALIENS' TRICK just yet. for(int i=1;i<=N;i++){ if(Segments[i].End>ActualSegments.back().End){ ActualSegments.push_back(Segments[i]); } } N=ActualSegments.size()-1; Pics=min(Pics,N); DP.resize(N+3,vector <long long>(Pics+3,0)); //Now, the DP. long long Ans=INF; for(int i=1;i<=N;i++){ DP[i][0]=INF; } for(int k=1;k<=Pics;k++){ DP[0][k]=INF; } Ans=INF; for(int i=1;i<=Pics;i++){ CalcDP(i); } for(int i=1;i<=Pics;i++){ Ans=min(Ans,DP[N][i]); } return Ans; }

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

aliens.cpp:42:16: error: invalid declarator before 'CurrentConvexHull'
   42 | vector <Lines> CurrentConvexHull;
      |                ^~~~~~~~~~~~~~~~~
aliens.cpp: In function 'void CalcDP(int)':
aliens.cpp:44:2: error: 'CurrentConvexHull' was not declared in this scope
   44 |  CurrentConvexHull.clear();
      |  ^~~~~~~~~~~~~~~~~
aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:60:18: error: no matching function for call to 'min(int&, long long int&)'
   60 |   Pics=min(Pics,N);
      |                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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 aliens.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
aliens.cpp:60:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   60 |   Pics=min(Pics,N);
      |                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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 aliens.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
aliens.cpp:60:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   60 |   Pics=min(Pics,N);
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
aliens.cpp:60:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   60 |   Pics=min(Pics,N);
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
aliens.cpp:60:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   60 |   Pics=min(Pics,N);
      |                  ^