結果
| 問題 |
No.622 点と三角柱の内外判定
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-04-04 14:21:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,500 ms |
| コード長 | 1,178 bytes |
| コンパイル時間 | 2,385 ms |
| コンパイル使用メモリ | 202,864 KB |
| 最終ジャッジ日時 | 2025-01-09 14:02:50 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
auto cross=[&](auto&&a,auto&&b){
std::vector<real>c(3);
for(lint i=0;i<3;i++){
lint j=(i+1)%3,k=(i+2)%3;
c.at(i)=a.at(j)*b.at(k)-a.at(k)*b.at(j);
}
return c;
};
auto dot=[&](auto&&a,auto&&b){
return std::inner_product(a.begin(),a.end(),b.begin(),0.0);
};
auto sub=[&](auto&&a,auto&&b){
std::vector<real>c(3);
for(lint i=0;i<3;i++)c.at(i)=a.at(i)-b.at(i);
return c;
};
std::vector<std::vector<real>>a(3,std::vector<real>(3));
for(auto&&v:a)for(real&x:v)std::cin>>x;
std::vector<real>b(3);
for(real&x:b)std::cin>>x;
for(lint i=0;i<3;i++){
if(dot(
cross(sub(a.at(2),a.at(0)),sub(a.at(2),a.at(1))),
cross(sub(b,a.at(0)),sub(b,a.at(1))))<0)
{
std::cout<<"NO"<<'\n';
return 0;
}
std::rotate(a.begin(),a.begin()+1,a.end());
}
std::cout<<"YES"<<'\n';
}
ngtkana