Submission #991431

#TimeUsernameProblemLanguageResultExecution timeMemory
991431AndreyPortal (BOI24_portal)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if(b < 0) { b = abs(b); } if(a < 0) { a = abs(a); } if(b == 0) { return a; } return gcd(b,a%b); } long long lcm(long long a, long long b) { a = abs(a); b = abs(b); return (a/gcd(a,b))*b; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n,a,b,ans = 0,x = 0; cin >> n; vector<pair<long long,long long>> haha(n); for(long long i = 0; i < n; i++) { cin >> a >> b; haha[i] = {a,b}; } vector<pair<long long,long long>> yay(0); for(long long i = 1; i < n; i++) { yay.push_back({haha[i].first-haha[i-1].first,haha[i].second-haha[i-1].second}); } for(long long i = 0; i < yay.size(); i++) { x = gcd(x,yay[i].second); for(long long j = i+1; j < min(i+2,yay.size()); j++) { if(yay[i].second == 0) { ans = gcd(ans,yay[i].first); } else if(yay[j].second == 0) { ans = gcd(ans,yay[j].first); } else { long long a = yay[i].first,b = -yay[i].second,c = yay[j].first,d = -yay[j].second; ans = gcd(ans,a*(lcm(b,d)/b)-c*(lcm(b,d)/d)); } } } if(ans*x == 0) { cout << -1; } else { cout << abs(ans*x); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:39:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(long long i = 0; i < yay.size(); i++) {
      |                          ~~^~~~~~~~~~~~
Main.cpp:41:54: error: no matching function for call to 'min(long long int, std::vector<std::pair<long long int, long long int> >::size_type)'
   41 |         for(long long j = i+1; j < min(i+2,yay.size()); j++) {
      |                                                      ^
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 Main.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:
Main.cpp:41:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'})
   41 |         for(long long j = i+1; j < min(i+2,yay.size()); j++) {
      |                                                      ^
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 Main.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:
Main.cpp:41:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'})
   41 |         for(long long j = i+1; j < min(i+2,yay.size()); j++) {
      |                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.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:
Main.cpp:41:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   41 |         for(long long j = i+1; j < min(i+2,yay.size()); j++) {
      |                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.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:
Main.cpp:41:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   41 |         for(long long j = i+1; j < min(i+2,yay.size()); j++) {
      |                                                      ^