結果

問題 No.199 星を描こう
ユーザー 👑 tatt61880tatt61880
提出日時 2021-07-11 00:56:59
言語 Kuin
(KuinC++ v.2021.9.17)
結果
WA  
実行時間 -
コード長 1,190 bytes
コンパイル時間 2,384 ms
コンパイル使用メモリ 159,676 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-14 18:37:31
合計ジャッジ時間 4,105 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

func main()
	var p: []@Point :: #[5]@Point
	for i(0, 4)
		var x: int :: cui@inputInt()
		var y: int :: cui@inputInt()
		do p[i] :: (#@Point).init(x, y)
	end for
	var ans: bool :: ^@convexHull(p) = 5
	do cui@print((ans ?("YES", "NO")) ~ "\n")
end func

class Point()
	+var x: int
	+var y: int
	+func init(x: int, y: int): Point
		do me.x :: x
		do me.y :: y
		ret me
	end func
	+func cross(a: Point, b: Point): int
		ret(a.x - me.x) * (b.y - me.y) - (a.y - me.y) * (b.x - me.x)
	end func
	+*func cmp(t: kuin@Class): int
		if(me.x < (t $ Point).x)
			ret - 1
		elif(me.x > (t $ Point).x)
			ret 1
		elif(me.y < (t $ Point).y)
			ret - 1
		elif(me.y > (t $ Point).y)
			ret 1
		end if
		ret 0
	end func
end class

; 凸包を求める。
func convexHull(p: []@Point): []@Point
	var n: int :: ^p
	var k: int :: 0
	var res: []@Point :: #[n]@Point
	do p.sort()
	for i(0, n - 1)
		while(k >= 2 & res[k - 2].cross(res[k - 1], p[i]) <= 0)
			do k :- 1
		end while
		do res[k] :: p[i]
		do k :+ 1
	end for
	var t: int :: k + 1
	for i(n - 2, 1, -1)
		while(k >= t & res[k - 2].cross(res[k - 1], p[i]) <= 0)
			do k :- 1
		end while
		do res[k] :: p[i]
		do k :+ 1
	end for
	ret res.sub(0, k)
end func
0