結果

問題 No.622 点と三角柱の内外判定
ユーザー ikdikd
提出日時 2017-12-27 19:19:12
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 980 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 96,044 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 17:48:50
合計ジャッジ時間 2,026 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 1 ms
4,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.typecons, std.math;

  alias P=Tuple!(double, "x", double, "y", double, "z");
  auto abc=new P[](3);
  foreach(i; 0..3) rd(abc[i].x, abc[i].y, abc[i].z);
  P d;
  rd(d.x, d.y, d.z);

  alias V=P;
  V vectorizeAtoB(P A, P B){ // from:A to:B
    return V(B.x-A.x, B.y-A.y, B.z-A.z);
  }
  double dot(V v1, V v2){
    return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z;
  }
  bool ok=true;
  foreach(i; 0..3){
    auto vd=vectorizeAtoB(abc[i], d),
         v1=vectorizeAtoB(abc[i], abc[(i-1+3)%3]),
         v2=vectorizeAtoB(abc[i], abc[(i+1)%3]);
    if(dot(vd, v1)<0 || dot(vd, v2)<0) ok=false;
  }

  if(ok) writeln("YES");
  else writeln("NO");
}


void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) write(e, " ");
  writeln();
}
0