제출 #1075732

#제출 시각아이디문제언어결과실행 시간메모리
1075732antonPortal (BOI24_portal)C++17
1 / 100
91 ms4948 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> #define P complex<int> int N; int cross(P a, P b){ return (a * conj(b)).imag(); } vector<int> vec(P p){ return {p.real(), p.imag()}; } void cancel(P& a, P& b, int dim){ if(vec(b)[dim] == 0){ return; } if(vec(a)[dim] == 0){ swap(a, b); return; } int nb_in = vec(b)[dim]/vec(a)[dim]; b -= nb_in *a; swap(a, b); cancel(a, b, dim); } void compress(vector<P>& v){ vector<P> res; for(int dim = 0; dim<2; dim++){ int cur_c = dim; for(int i = dim; i<v.size(); i++){ if(vec(v[i])[dim] != 0){ cur_c = i; } } swap(v[dim], v[cur_c]); for(int i = dim+1; i<v.size(); i++){ cancel(v[dim], v[i], dim); } res.push_back(v[dim]); } v = res; } signed main(){ cin>>N; vector<P> portals(N); for(int i = 0; i<N; i++){ pii pos; cin>>pos.first>>pos.second; portals[i] = {pos.first, pos.second}; } P origin = portals.back(); for(P& portal: portals){ portal -= origin; } portals.pop_back(); vector<P> base = portals; if(N<3){ cout<<-1<<endl; return 0; } compress(base); if(base.size()<2){ cout<<-1<<endl; return 0; } cout<<abs(cross(base[0], base[1]))<<endl; }

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

Main.cpp: In function 'void compress(std::vector<std::complex<long long int> >&)':
Main.cpp:36:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::complex<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i = dim; i<v.size(); i++){
      |                          ~^~~~~~~~~
Main.cpp:43:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::complex<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int i = dim+1; i<v.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...