結果
| 問題 | No.199 星を描こう |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-21 22:45:18 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 2 ms / 2,000 ms |
| + 596µs | |
| コード長 | 1,495 bytes |
| 記録 | |
| コンパイル時間 | 1,731 ms |
| コンパイル使用メモリ | 193,504 KB |
| 実行使用メモリ | 9,868 KB |
| 最終ジャッジ日時 | 2026-10-21 22:45:45 |
| 合計ジャッジ時間 | 4,233 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
struct Point{
ll x, y;
Point(ll x=0, ll y=0):x(x), y(y){}
bool operator<(const Point& other)const{ //sortに必要
if(x!=other.x) return x<other.x;
else return y<other.y;
}
bool operator==(const Point& other)const{ //uniqueに必要
return x==other.x&&y==other.y;
}
};
ll cross(Point o, Point a, Point b){
//OA x OB
return (a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x);
}
vector<Point> Convex_Hull(vector<Point> tar){
sort(tar.begin(), tar.end());
tar.erase(unique(tar.begin(), tar.end()), tar.end());
int n=tar.size();
if(n<=1) return tar;
vector<vector<Point>> down_up(2);
for(int i=0; i<2; i++){
for(auto pt:tar){
while((int)down_up[i].size()>=2){
Point o=down_up[i][(int)down_up[i].size()-2];
Point a=down_up[i][(int)down_up[i].size()-1];
if(cross(o, a, pt)<=0) down_up[i].pop_back(); //一直線も削除
//if(cross(o, a, pt)<0) down.pop_back(); //直線上の点は残す
else break;
}
down_up[i].push_back(pt);
}
reverse(tar.begin(), tar.end());
down_up[i].pop_back();
}
down_up[0].insert(down_up[0].end(), down_up[1].begin(), down_up[1].end());
return down_up[0];
}
int main(void){
vector<Point> p;
for(int i=0; i<5; i++){
ll x, y; cin >> x >> y;
p.emplace_back(x, y);
}
auto ch=Convex_Hull(p);
cout << (ch.size()==5?"YES":"NO") << endl;
return 0;
}