結果

問題 No.199 星を描こう
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2015-04-29 00:34:08
言語 Ruby
(3.3.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 1,167 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 11,364 KB
実行使用メモリ 15,296 KB
最終ジャッジ日時 2023-08-28 18:37:16
合計ジャッジ時間 3,296 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,136 KB
testcase_01 AC 77 ms
15,256 KB
testcase_02 AC 75 ms
15,036 KB
testcase_03 AC 74 ms
15,056 KB
testcase_04 AC 75 ms
15,036 KB
testcase_05 AC 74 ms
15,252 KB
testcase_06 AC 76 ms
15,132 KB
testcase_07 AC 75 ms
15,292 KB
testcase_08 AC 77 ms
15,176 KB
testcase_09 AC 75 ms
15,056 KB
testcase_10 AC 75 ms
15,216 KB
testcase_11 AC 75 ms
15,248 KB
testcase_12 AC 75 ms
15,144 KB
testcase_13 AC 75 ms
15,040 KB
testcase_14 AC 76 ms
15,056 KB
testcase_15 AC 75 ms
15,072 KB
testcase_16 AC 76 ms
15,036 KB
testcase_17 AC 76 ms
15,040 KB
testcase_18 AC 75 ms
15,132 KB
testcase_19 AC 76 ms
15,296 KB
testcase_20 AC 75 ms
15,112 KB
testcase_21 AC 75 ms
15,192 KB
testcase_22 AC 75 ms
15,132 KB
testcase_23 AC 75 ms
15,036 KB
testcase_24 AC 75 ms
15,160 KB
testcase_25 AC 76 ms
15,120 KB
testcase_26 AC 75 ms
15,156 KB
testcase_27 AC 76 ms
15,032 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# http://yukicoder.me/problems/433
# No.199 星を描こう

class Point
    attr_accessor :x, :y
    def initialize(x_, y_)
        self.x = x_
        self.y = y_
    end
end

def cross(a, b)
    (a.x * b.y - a.y*b.x)
end

def cross2(a, b, o)
    cross(Point.new(a.x-o.x, a.y-o.y), Point.new(b.x-o.x, b.y-o.y))
end

points = []
N = 5
N.times{
    x, y = gets.split.map(&:to_i)
    points << Point.new(x,y)
}
allok = true
(0...N).each{|i|
    #puts "======= i=#{i} ========="
    o = points[i]
    ok = false
    (0...N).each{|j|
        #puts "  ======= j=#{j} ========="
        if j == i
            next
        end
        a = points[j]
        failed = false
        (0...N).each{|k|
            #puts "    ======= k=#{k} ========="
            if(k==j || k==i)
                next
            end
            b = points[k]
            if cross2(a, b, o)>0
                #puts "cross2 ok"
            else
                failed = true
                #puts "cross2 ng"
            end
        }
        if failed == false
            ok = true
            #puts "ok=true"
        end
    }
    allok &&= ok
}
if allok
    puts "YES"
else
    puts "NO"
end
0