結果
| 問題 |
No.947 ABC包囲網
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-21 13:17:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,429 bytes |
| コンパイル時間 | 721 ms |
| コンパイル使用メモリ | 81,076 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-05 08:07:06 |
| 合計ジャッジ時間 | 6,271 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 51 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<cmath>
#define REP(i,j,N) for(int i=j,__i=N;i<__i;++i)
struct Point{
double x;
double y;
Point(double x_=0,double y_=0){
x=x_;
y=y_;
}
Point(const Point &dst){
x=dst.x;
y=dst.y;
}
const std::string str()const{
std::ostringstream osm;
char buf[128];
sprintf(buf,"%.16f",x);
osm<<"("<<buf;
sprintf(buf,"%.16f",y);
osm<<","<<buf<<")";
return osm.str();
}
};
bool operator<(const Point &src,const Point &dst){
return src.x<dst.x;
}
int N;
bool input(){
std::cin>>N;
return true;
}
double getk(Point &left,Point &right){
double k=left.y;
return left.y+(0-left.x)*(right.y-left.y)/(right.x-left.x);
}
int solve(){
using namespace std;
vector<Point> points(N),tmp(3);
Point point,left;
double k1,k2;
int count=0;
REP(i,0,2)
cin>>points[i].x>>points[i].y;
REP(i,2,N){
cin>>points[i].x>>points[i].y;
REP(j,0,i-1){
tmp[0]=points[j];
tmp[1]=points[j+1];
tmp[2]=points[i];
sort(tmp.begin(),tmp.end());
if(tmp[0].x<=0&&tmp[2].x>=0){
k1=getk(tmp[0],tmp[1]);
k2=getk(tmp[0],tmp[2]);
if((k1!=0&&k2!=0)&&((k1>0)^(k2>0)))
{
count++;
//cout<<tmp[0].str()<<tmp[1].str()<<tmp[2].str()<<endl;
//cout<<getk(tmp[0],tmp[1])<<" "<<getk(tmp[0],tmp[2])<<endl;
}
}
}
}
return count;
}
int main(){
input();
int res=solve();
std::cout<<res<<std::endl;
}