結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
|
提出日時 | 2024-10-13 21:48:28 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,239 bytes |
コンパイル時間 | 5,622 ms |
コンパイル使用メモリ | 209,408 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 21:48:35 |
合計ジャッジ時間 | 6,556 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
module main;import std;// https://github.com/drken1215/algorithm/blob/master/Geometry/ より// 2次元ベクトル(整数版)struct Point {long x, y;// 加減算Point opOpAssign(string op)(Point rhs)if (op == "+" || op == "-"){mixin("x " ~ op ~ "= rhs.x;");mixin("y " ~ op ~ "= rhs.y;");return this;}Point opBinary(string op)(Point rhs) constif (op == "+" || op == "-"){mixin("return Point(x " ~ op ~ " rhs.x, y " ~ op ~ " rhs.y);");}// 外積long det(Point rhs) const{return x * rhs.y - y * rhs.x;}// 内積long dot(Point rhs) const{return x * rhs.x + y * rhs.y;}// ノルムlong norm() const{return dot(this);}// 標準出力に使うstring toString() const{return format("%d %d", x, y);}}void main(){// 入力Point a, b, c;readln.chomp.formattedRead("%d %d %d %d %d %d", a.x, a.y, b.x, b.y, c.x, c.y);// 答えの計算と出力Point e = b - a, f = c - a;if (e.dot(f) == 0 && e.norm == f.norm) {writeln(c + e);return;}e = a - b, f = c - b;if (e.dot(f) == 0 && e.norm == f.norm) {writeln(c + e);return;}e = a - c, f = b - c;if (e.dot(f) == 0 && e.norm == f.norm) {writeln(b + e);return;}writeln(-1);}