結果
| 問題 | No.199 星を描こう |
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2024-07-13 00:33:16 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,420 bytes |
| コンパイル時間 | 1,048 ms |
| コンパイル使用メモリ | 103,772 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-13 00:33:19 |
| 合計ジャッジ時間 | 2,600 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
ll cross(ll a,ll b,ll c,ll d){
return a * d - c * b;
}
int ccw(pair<ll,ll> a,pair<ll,ll> b,pair<ll,ll> c){
ll dx = b.first - a.first;
ll dy = b.second - a.second;
ll ddx = c.first - b.first;
ll ddy = c.second - b.second;
ll now = cross(dx,dy,ddx,ddy);
if(now>0) return 1;
if(now<0) return -1;
return 0;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n = 5;
vector<ll> x(n),y(n);
for(int i = 0;i<n;i++) cin>>x[i]>>y[i];
vector<pair<ll,ll>> use;
for(int i = 0;i<n;i++) use.push_back(make_pair(x[i],y[i]));
sort(use.begin(),use.end());
vector<pair<ll,ll>> lower,upper;
{
for(int i = 0;i<use.size();i++){
while(upper.size()>=2){
int m = upper.size();
if(ccw(upper[m-2],upper[m-1],use[i])!=-1) upper.pop_back();
else break;
}
upper.push_back(use[i]);
}
}
{
for(int i = 0;i<use.size();i++){
while(lower.size()>=2){
int m = lower.size();
if(ccw(lower[m-2],lower[m-1],use[i])!=1) lower.pop_back();
else break;
}
lower.push_back(use[i]);
}
}
if(upper.size()+lower.size()==7) cout<<"YES\n";
else cout<<"NO\n";
}
momoyuu