제출 #1118797

#제출 시각아이디문제언어결과실행 시간메모리
1118797YSH2020Portal (BOI24_portal)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int __int128 int ans_x = 0; int gcd(int a, int b) { if (a < 0) a *= -1; if (b < 0) b *= -1; if (b > a) swap(a, b); if (b == 0) return a; return gcd(b, a%b); } pair<int, int> zero_vector (pair<int, int> a, pair<int, int> b) { if (a.first < 0) a = {-a.first, -a.second}; if (b.first < 0) b = {-b.first, -b.second}; if (b.first > a.first) swap(a, b); if (b.first == 0) {ans_x = gcd(ans_x, b.second); return a;} return zero_vector(b, {a.first%b.first, a.second-b.second*(a.first/b.first)}); } signed main() { long long n; cin >> n; if (n < 3) {cout << -1; return 0;} long long x[n], y[n]; for (int i = 0; i < n; i++) {cin >> x[i] >> y[i];} vector <pair<int, int>> a; for (int i = 1; i < n; i++) { if (x[i] == x[i-1]) { ans_x = gcd(ans_x, y[i]-y[i-1]); } else if (x[i] > x[i-1]) { a.push_back({x[i]-x[i-1], y[i]-y[i-1]}); } else a.push_back({x[i-1]-x[i], y[i-1]-y[i]}); } while (a.size() >= 2) { auto i = a.back(); a.pop_back(); a[0] = zero_vector(a[0], i); } if (a.size() == 0 or a[0].first == 0 or ans_x == 0) cout << -1; else {long long ans = a[0].first*ans_x; cout << ans;} }

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

In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from Main.cpp:1:
/usr/include/c++/10/numeric: In instantiation of 'constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = long long int; std::common_type_t<_Mn, _Nn> = __int128]':
Main.cpp:29:43:   required from here
/usr/include/c++/10/numeric:133:21: error: static assertion failed: gcd arguments are integers
  133 |       static_assert(is_integral_v<_Mn>, "gcd arguments are integers");
      |                     ^~~~~~~~~~~~~~~~~~
/usr/include/c++/10/numeric: In instantiation of 'constexpr std::common_type_t<_Mn, _Nn> std::__detail::__gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = long long int; std::common_type_t<_Mn, _Nn> = __int128]':
/usr/include/c++/10/numeric:139:29:   required from 'constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = long long int; std::common_type_t<_Mn, _Nn> = __int128]'
Main.cpp:29:43:   required from here
/usr/include/c++/10/numeric:105:39: error: use of deleted function 'void std::__detail::__abs_integral(bool)'
  105 |  : __n == 0 ? __detail::__abs_integral(__m)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/numeric:98:8: note: declared here
   98 |   void __abs_integral(bool) = delete;
      |        ^~~~~~~~~~~~~~
/usr/include/c++/10/numeric: In instantiation of 'constexpr std::common_type_t<_Mn, _Nn> std::__detail::__gcd(_Mn, _Nn) [with _Mn = long long int; _Nn = __int128; std::common_type_t<_Mn, _Nn> = __int128]':
/usr/include/c++/10/numeric:106:19:   required from 'constexpr std::common_type_t<_Mn, _Nn> std::__detail::__gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = long long int; std::common_type_t<_Mn, _Nn> = __int128]'
/usr/include/c++/10/numeric:139:29:   required from 'constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = long long int; std::common_type_t<_Mn, _Nn> = __int128]'
Main.cpp:29:43:   required from here
/usr/include/c++/10/numeric:104:49: error: use of deleted function 'void std::__detail::__abs_integral(bool)'
  104 |       return __m == 0 ? __detail::__abs_integral(__n)
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/numeric:98:8: note: declared here
   98 |   void __abs_integral(bool) = delete;
      |        ^~~~~~~~~~~~~~
/usr/include/c++/10/numeric: In instantiation of 'constexpr std::common_type_t<_Mn, _Nn> std::__detail::__gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = __int128; std::common_type_t<_Mn, _Nn> = __int128]':
/usr/include/c++/10/numeric:106:19:   recursively required from 'constexpr std::common_type_t<_Mn, _Nn> std::__detail::__gcd(_Mn, _Nn) [with _Mn = long long int; _Nn = __int128; std::common_type_t<_Mn, _Nn> = __int128]'
/usr/include/c++/10/numeric:106:19:   required from 'constexpr std::common_type_t<_Mn, _Nn> std::__detail::__gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = long long int; std::common_type_t<_Mn, _Nn> = __int128]'
/usr/include/c++/10/numeric:139:29:   required from 'constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = long long int; std::common_type_t<_Mn, _Nn> = __int128]'
Main.cpp:29:43:   required from here
/usr/include/c++/10/numeric:104:49: error: use of deleted function 'void std::__detail::__abs_integral(bool)'
  104 |       return __m == 0 ? __detail::__abs_integral(__n)
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/numeric:98:8: note: declared here
   98 |   void __abs_integral(bool) = delete;
      |        ^~~~~~~~~~~~~~
/usr/include/c++/10/numeric:105:39: error: use of deleted function 'void std::__detail::__abs_integral(bool)'
  105 |  : __n == 0 ? __detail::__abs_integral(__m)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/numeric:98:8: note: declared here
   98 |   void __abs_integral(bool) = delete;
      |        ^~~~~~~~~~~~~~