Submission #1049468

#TimeUsernameProblemLanguageResultExecution timeMemory
1049468shenfe1Portal (BOI24_portal)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #pragma optimize("Ofast") #pragma target("avx2") using namespace std; #define ll long long #define ld long double #define pb push_back #define pii pair<int,int> #define all(v) v.begin(),v.end() #define F first #define S second #define mem(a,i) memset(a,i,sizeof(a)) #define sz(s) (int)s.size() #define ppb pop_back #define lb lower_bound #define ub upper_bound #define in insert #define int ll const int MAX=3e5+15; const ll inf=1e18+1; const int mod=998244353; const int mod1=1e9+9; int dx[8]={1,0,-1,0,1,-1,-1,1}; int dy[8]={0,1,0,-1,1,-1,1,-1}; int binpow(int a,int n){ if(!n)return 1; if(n%2==1)return a*binpow(a,n-1)%mod; int k=binpow(a,n/2); return k*k%mod; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n; pair<pair<int,__int128>,pair<int,__int128>> gcd(pair<int,__int128> a,pair<int,__int128> b){ if(a.F==0||b.F==0)return {a,b}; if(a.F<b.F)swap(a,b); int c=a.F/b.F; a.F%=b.F; a.S-=b.S*c; return gcd(b,a); } int x[MAX],y[MAX]; void solve(){ cin>>n; if(n<=2){ cout<<-1<<"\n"; return; } for(int i=1;i<=n;i++)cin>>x[i]>>y[i]; __int128 g=0; set<pair<int,__int128>> vec; for(int i=2;i<=n;i++){ // if(x[i]==x[1]){ // if(y[i]!=y[1]){ // __int128 f=y[i]-y[1]; // g=gcd(g,f); // } // } // else{ // if(x[i]-x[1]>0)vec.insert({x[i]-x[1],y[i]-y[1]}); // else vec.insert({x[1]-x[i],y[1]-y[i]}); // } } while(sz(vec)>=2){ pair<int,__int128> a=*vec.begin(); vec.erase(vec.begin()); pair<int,__int128> b=*vec.begin(); vec.erase(vec.begin()); pair<pair<int,__int128>,pair<int,__int128>> res=gcd(a,b); if(res.F.F==0){ if(res.F.S!=0){ g=gcd(g,res.F.S); } } else vec.insert(res.F); if(res.S.F==0){ if(res.S.S!=0){ g=gcd(g,res.S.S); } } else vec.insert(res.S); } if(vec.empty()||g==0)cout<<-1<<"\n"; else{ // cout<<g<<" "<<vec.begin()->F<<" "<<vec.begin()->S<<"\n"; int G=g; cout<<G*vec.begin()->F<<"\n"; } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; // cin>>t; while(t--){ solve(); } }

Compilation message (stderr)

Main.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize("Ofast")
      | 
Main.cpp:4: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    4 | #pragma target("avx2")
      | 
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:82:32:   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:82:32:   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;
      |        ^~~~~~~~~~~~~~