結果

問題 No.199 星を描こう
ユーザー TatamoTatamo
提出日時 2016-11-15 18:34:11
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 2,081 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 39,296 KB
最終ジャッジ日時 2024-04-21 01:39:26
合計ジャッジ時間 2,710 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
39,040 KB
testcase_01 AC 61 ms
39,040 KB
testcase_02 AC 61 ms
39,040 KB
testcase_03 AC 62 ms
39,040 KB
testcase_04 AC 63 ms
39,168 KB
testcase_05 AC 69 ms
39,168 KB
testcase_06 AC 61 ms
39,168 KB
testcase_07 AC 62 ms
39,040 KB
testcase_08 AC 62 ms
39,168 KB
testcase_09 AC 63 ms
39,296 KB
testcase_10 AC 61 ms
39,040 KB
testcase_11 AC 62 ms
39,296 KB
testcase_12 AC 62 ms
39,168 KB
testcase_13 AC 61 ms
39,040 KB
testcase_14 AC 63 ms
39,040 KB
testcase_15 AC 63 ms
39,040 KB
testcase_16 AC 64 ms
39,040 KB
testcase_17 AC 63 ms
39,296 KB
testcase_18 AC 63 ms
39,296 KB
testcase_19 AC 62 ms
39,168 KB
testcase_20 AC 61 ms
39,168 KB
testcase_21 AC 62 ms
39,040 KB
testcase_22 AC 63 ms
39,040 KB
testcase_23 AC 63 ms
39,040 KB
testcase_24 AC 63 ms
39,296 KB
testcase_25 AC 62 ms
39,296 KB
testcase_26 AC 61 ms
39,168 KB
testcase_27 AC 61 ms
39,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

var input = require("fs").readFileSync("/dev/stdin", "utf8");
input = input.split("\n");
var point = [];
for (var i = 0; i < 5; i++) {
    var tmp = input[i].split(" ");
    point.push([+tmp[0], +tmp[1]]);
}
var count = 0; // 条件を満たす2点の組の数
var pair = [];
for (var p1 = 0; p1 < 5; p1++) {
    for (var p2 = p1 + 1; p2 < 5; p2++) {
        //console.log("points: ", p1, p2);
        var flg = true;
        var cnt_p = 0; // +
        var cnt_m = 0; // -
        for (var p3 = 0; p3 < 5; p3++) {
            if (p3 == p1 || p3 == p2)
                continue;
            var dx1 = point[p2][0] - point[p1][0];
            var dy1 = point[p2][1] - point[p1][1];
            var dx2 = point[p3][0] - point[p1][0];
            var dy2 = point[p3][1] - point[p1][1];
            var deg1 = Math.atan2(dy1, dx1);
            var deg2 = Math.atan2(dy2, dx2);
            var deg = (deg2 - deg1);
            //console.log([dx1, dy1], [dx2, dy2]);
            //console.log(p1,p2,p3,"deg: ", deg*180/Math.PI);
            if (deg > Math.PI)
                deg -= Math.PI * 2;
            if (deg < -Math.PI)
                deg += Math.PI * 2;
            if ((deg * 180 / Math.PI) % 180 == 0) {
                flg = false;
                break;
            }
            else if (deg < 0)
                cnt_m += 1;
            else if (deg > 0)
                cnt_p += 1;
        }
        if (cnt_p == 2 && cnt_m == 1 ||
            cnt_p == 1 && cnt_m == 2) {
        }
        else {
            flg = false;
        }
        if (flg) {
            count += 1;
            pair.push([p1, p2]);
        }
    }
}
//console.log("count: ", count);
//console.log(pair);
if (count == 5) {
    var cnt = [0, 0, 0, 0, 0];
    for (var i = 0; i < 5; i++) {
        cnt[pair[i][0]]++;
        cnt[pair[i][1]]++;
    }
    var flg = true;
    for (var i = 0; i < 5; i++) {
        if (cnt[i] != 2) {
            flg = false;
            break;
        }
    }
    if (flg)
        console.log("YES");
    else
        console.log("NO");
}
else
    console.log("NO");
0