제출 #1045036

#제출 시각아이디문제언어결과실행 시간메모리
1045036owoovoPortal (BOI24_portal)C++17
40 / 100
18 ms7880 KiB
#include <bits/stdc++.h> #define ll long long #define pll pair<ll,ll> #define F first #define S second using namespace std; vector<pll> point,vc; ll n; 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++){ 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})); } 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(0ll,0ll)){ 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; for(int i=0;i<s.size();i++){ if(s[i]!=0){ if(sg==0)sg=abs(s[i]); else sg=gcd(sg,abs(s[i])); } } if(now.F==0||sg==0){ cout<<"-1\n"; }else{ cout<<now.F*sg<<"\n"; } return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
#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...