제출 #1045040

#제출 시각아이디문제언어결과실행 시간메모리
1045040owoovoPortal (BOI24_portal)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ll __int128_t #define pll pair<ll,ll> #define F first #define S second using namespace std; const ll zo=0; vector<pll> point,vc; long long n; ll abs2(ll a){ return max(a,-a); } pll fd(pll a){ return max(a,{-a.F,-a.S}); } void _gcd(pll &a,pll &b){ if(a.F==0||b.F==0)return; if(a.F<b.F)swap(a,b); ll g=a.F/b.F; a.F-=b.F*g; a.S-=b.S*g; _gcd(b,a); return ; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>n; for(int i=0;i<n;i++){ long long x,y; cin>>x>>y; point.push_back({x,y}); } for(int i=1;i<n;i++){ vc.push_back(fd({point[i].F-point[0].F,point[i].S-point[0].S})); } pll now={0,0}; vector<ll> s; for(int i=0;i<n-1;i++){ if(vc[i].F==0){ s.push_back(vc[i].S); }else{ if(now==make_pair(zo,zo)){ now=vc[i]; }else{ _gcd(now,vc[i]); if(now.F==0)swap(now,vc[i]); s.push_back(vc[i].S); } } } ll sg=0; int len=s.size(); for(int i=0;i<len;i++){ if(s[i]!=0){ if(sg==zo)sg=abs2(s[i]); else sg=gcd(sg,abs2(s[i])); } } if(now.F==0||sg==0){ cout<<"-1\n"; }else{ cout<<(long long)(now.F*sg)<<"\n"; } return 0; }

컴파일 시 표준 에러 (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 = __int128; std::common_type_t<_Mn, _Nn> = __int128]':
Main.cpp:60:38:   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:134:21: error: static assertion failed: gcd arguments are integers
  134 |       static_assert(is_integral_v<_Nn>, "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 = __int128; 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 = __int128; std::common_type_t<_Mn, _Nn> = __int128]'
Main.cpp:60:38:   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;
      |        ^~~~~~~~~~~~~~