結果

問題 No.199 星を描こう
コンテスト
ユーザー ゴリポン先生
提出日時 2026-02-01 22:38:15
言語 D
(dmd 2.111.0)
結果
WA  
実行時間 -
コード長 1,336 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,423 ms
コンパイル使用メモリ 187,568 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-02-01 22:38:21
合計ジャッジ時間 4,663 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/core/checkedint.d(814): Warning: cannot inline function `core.checkedint.mulu!().mulu`
ulong mulu()(ulong x, uint y, ref bool overflow)
      ^

ソースコード

diff #
raw source code

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) const
		if (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);
	}
}
// n個からk個取る組み合わせ
T[][] comb(T)(in T[] arr, in int k)
{
	if (k == 0) return [[]];
	typeof(return) result;
	foreach (immutable i, immutable x; arr)
		foreach (suffix; arr[i + 1 .. $].comb(k - 1))
			result ~= x ~ suffix;
	return result;
}

void main()
{
	// 入力
	Point[5] ps;
	foreach (i; 0 .. 5)
		readln.chomp.formattedRead("%d %d", ps[i].x, ps[i].y);
	// 答えの計算と出力
	foreach (set; comb([0, 1, 2, 3, 4], 3)) {
		// 5点のうちどの3点も一直線上にないかどうか調べる
		if ((ps[set[1]] - ps[set[0]]).det(ps[set[2]] - ps[set[0]]) == 0) {
			writeln("NO");
			return;
		}
	}
	writeln("YES");
}
0