Submission #1076559

#TimeUsernameProblemLanguageResultExecution timeMemory
1076559raphaelpPortal (BOI24_portal)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; long long X, Y; cin >> X >> Y; vector<pair<__int128, __int128>> Tab; for (long long i = 0; i < N - 1; i++) { long long x, y; cin >> x >> y; Tab.push_back({x - X, y - Y}); } if (N <= 2) { cout << -1; return 0; } vector<pair<__int128, __int128>> Tab2; random_shuffle(Tab.begin(), Tab.end()); while (!Tab.empty() && Tab[0].first == 0) { Tab2.push_back(Tab[0]); swap(Tab[0], Tab[Tab.size() - 1]); Tab.pop_back(); } while (Tab.size() > 1) { while (Tab.size() > 1 && Tab[1].first == 0) { swap(Tab[1], Tab[Tab.size() - 1]); Tab2.push_back(Tab[Tab.size() - 1]); Tab.pop_back(); } if (Tab.size() == 1) break; if (abs(Tab[1].first) < abs(Tab[0].first)) swap(Tab[1], Tab[0]); __int128 x = Tab[1].first / Tab[0].first; Tab[1].first -= Tab[0].first * x; Tab[1].second -= Tab[0].second * x; if (Tab[1].first == 0 && Tab[1].second != 0) { x = Tab[0].second / Tab[1].second; Tab[0].second -= Tab[1].second * x; } } while (!Tab2.empty() && Tab2[0].second == 0) { swap(Tab2[0], Tab2[Tab2.size() - 1]); Tab2.pop_back(); } while (Tab2.size() > 1) { while (Tab2.size() > 1 && Tab2[1].second == 0) { swap(Tab2[1], Tab2[Tab2.size() - 1]); Tab2.pop_back(); } if (Tab2.size() == 1) break; if (abs(Tab2[1].second) < abs(Tab2[0].second)) swap(Tab2[1], Tab2[0]); long long x = Tab2[1].second / Tab2[0].second; Tab2[1].second -= Tab2[0].second * x; } if (Tab2.empty()) cout << -1; else cout << abs((long long)Tab[0].first * (long long)Tab2[0].second); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:39:29: error: call of overloaded 'abs(__int128&)' is ambiguous
   39 |         if (abs(Tab[1].first) < abs(Tab[0].first))
      |                             ^
In file included from /usr/include/c++/10/bits/std_abs.h:38,
                 from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/stdlib.h:840:12: note: candidate: 'int abs(int)'
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
Main.cpp:39:49: error: call of overloaded 'abs(__int128&)' is ambiguous
   39 |         if (abs(Tab[1].first) < abs(Tab[0].first))
      |                                                 ^
In file included from /usr/include/c++/10/bits/std_abs.h:38,
                 from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/stdlib.h:840:12: note: candidate: 'int abs(int)'
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
Main.cpp:64:31: error: call of overloaded 'abs(__int128&)' is ambiguous
   64 |         if (abs(Tab2[1].second) < abs(Tab2[0].second))
      |                               ^
In file included from /usr/include/c++/10/bits/std_abs.h:38,
                 from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/stdlib.h:840:12: note: candidate: 'int abs(int)'
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
Main.cpp:64:53: error: call of overloaded 'abs(__int128&)' is ambiguous
   64 |         if (abs(Tab2[1].second) < abs(Tab2[0].second))
      |                                                     ^
In file included from /usr/include/c++/10/bits/std_abs.h:38,
                 from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/stdlib.h:840:12: note: candidate: 'int abs(int)'
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~