Submission #70066493


Source Code Expand

const inputText = require("fs").readFileSync("/dev/stdin", "utf8");
/** @type {string[][]} - スペース区切りと改行区切りをそのまま2次元配列に変えた状態 */
const input = inputText.trim().split("\n").map(row => row.split(" "));

const [N, M] = input[0].map(n => +n);
const edges = [];
for (let i = 1; i <= M; i++) {
    edges.push({
        u: +input[i][0],
        v: +input[i][1],
    });
}

let min = Infinity;
for (let i = 0; i < 2 ** N; i++) {
    const node_colors = [null, ...Array.from(i.toString(2).padStart(N, "0"))];
    let count = 0;
    edges.forEach(({u, v}) => {
        if (node_colors[u] === node_colors[v]) count++;
    });
    if (min > count) {
        min = count;
    }
}
console.log(min);

Submission Info

Submission Time
Task C - Bipartize
User AXT_AyaKoto
Language JavaScript (Node.js 18.16.1)
Score 350
Code Size 761 Byte
Status AC
Exec Time 66 ms
Memory 47088 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 25
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 42 ms 42556 KiB
00_sample_01.txt AC 41 ms 42776 KiB
00_sample_02.txt AC 66 ms 46168 KiB
01_random_03.txt AC 42 ms 42764 KiB
01_random_04.txt AC 42 ms 43184 KiB
01_random_05.txt AC 43 ms 42756 KiB
01_random_06.txt AC 44 ms 42772 KiB
01_random_07.txt AC 40 ms 46440 KiB
01_random_08.txt AC 43 ms 43824 KiB
01_random_09.txt AC 40 ms 43852 KiB
01_random_10.txt AC 45 ms 43684 KiB
01_random_11.txt AC 45 ms 47008 KiB
01_random_12.txt AC 46 ms 47088 KiB
01_random_13.txt AC 46 ms 47008 KiB
01_random_14.txt AC 45 ms 46912 KiB
01_random_15.txt AC 40 ms 46528 KiB
01_random_16.txt AC 49 ms 46992 KiB
01_random_17.txt AC 42 ms 42752 KiB
01_random_18.txt AC 42 ms 42756 KiB
01_random_19.txt AC 45 ms 42764 KiB
01_random_20.txt AC 45 ms 42712 KiB
01_random_21.txt AC 43 ms 42760 KiB
01_random_22.txt AC 40 ms 42752 KiB
01_random_23.txt AC 45 ms 42728 KiB
01_random_24.txt AC 44 ms 42848 KiB