結果

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

テストケース

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

ソースコード

diff #

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

  alias P=Tuple!(long, "x", long, "y", long, "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(const P A, const P B){ // from:A to:B
    return V(B.x-A.x, B.y-A.y, B.z-A.z);
  }
  long dot(const V v1, const V v2){
    return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z;
  }
  int minus=0;
  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)<0L) minus++;
    if(dot(vd, v2)<0L) minus++;
  }
  
  if(minus<=1) 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