제출 #1041429

#제출 시각아이디문제언어결과실행 시간메모리
1041429owoovoPortal (BOI24_portal)C++17
11 / 100
36 ms4852 KiB
#include <bits/stdc++.h> #define ll long long #define pll pair<ll,ll> #define F first #define S second using namespace std; pll fd(pll x){ return max(x,{-x.F,-x.S}); } pll base(pll x){ if(x.F==0)return {0,1}; else if(x.S==0)return {1,0}; else { ll g=gcd(abs(x.F),abs(x.S)); return {x.F/g,x.S/g}; } } pll gg(pll x,pll y){ if(x.F==0){ return {0,gcd(abs(x.S),abs(y.S))}; }else if(x.S==0){ return {gcd(abs(x.F),abs(y.F)),0}; }else{ ll gf=gcd(abs(x.F),abs(y.F)),gs=gcd(abs(x.S),abs(y.S)); return {gf,gs}; } } int n; vector<pll> point; vector<pll> vc; vector<pll> use; int main(){ // ios::sync_with_stdio(0); // cin.tie(0); cin>>n; for(int i=0;i<n;i++){ ll 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})); } for(auto x:vc){ int ok=1; for(auto y:use){ if(base(x)==base(y)){ y=gg(x,y); ok=0; break; } } if(ok==1){ use.push_back(x); if(use.size()>=3){ break; } } } if(use.size()>=3){ cout<<"1\n"; }else if(use.size()<=1){ cout<<"-1\n"; }else{ sort(use.begin(),use.end()); if(use[0].F==0){ cout<<abs(use[0].S*use[1].F)<<"\n"; }else{ ll g=gcd(abs(use[0].F),abs(use[1].F)); ll diff=abs(use[0].S*use[1].F/g-use[1].S*use[0].F/g); cout<<g*diff<<"\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...