제출 #1076359

#제출 시각아이디문제언어결과실행 시간메모리
1076359antonPortal (BOI24_portal)C++17
40 / 100
71 ms3420 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_all(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; } } if(vec(v[cur_c])[dim]==0){ continue; } 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; } void compress_last(vector<P>& v){ vector<P> res; for(int dim = 0; dim<2; dim++){ for(int i = 2; 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[0]}; for(auto e: portals){ if(cross(e, base[0])!=0){ base.push_back(e); break; } } if(N<3|| base.size()<2){ cout<<-1<<endl; return 0; } compress_all(base); for(auto e: portals){ base.push_back(e); compress_last(base); } cout<<abs(cross(base[0], base[1]))<<endl; }

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

Main.cpp: In function 'void compress_all(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:46: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]
   46 |         for(int i = dim+1; i<v.size(); i++){
      |                            ~^~~~~~~~~
Main.cpp: In function 'void compress_last(std::vector<std::complex<long long int> >&)':
Main.cpp:57:25: 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]
   57 |         for(int i = 2; 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...