Submission #70048526
Source Code Expand
function main(stdin) {
// eslint-disable-next-line unused-imports/no-unused-vars, no-unused-vars
const { next, nextstr, nextbig, nexts, nextssort, nextm, xArray } = makeInputReader(stdin)
const [n, m] = nexts(2)
const e = []
for (let i = 0; i < m; i++) {
const [u, v] = nexts(2)
e.push([u - 1, v - 1])
}
let res = Infinity
for (let i = 0; i < (1 << n) - 1; i++) {
let cross = 0
for (const [u, v] of e) {
if (((i >> u) & 1) !== ((i >> v) & 1)) {
cross++
}
}
const del = m - cross
res = Math.min(res, del)
}
return res
}
function makeInputReader(input) {
const cin = input.trim().split(/ |\n/)
let cid = 0
function createNDArray(shape, fillFn) {
if (shape.length === 0)
return fillFn()
const [dim, ...rest] = shape
return Array.from({ length: dim }, () => createNDArray(rest, fillFn))
}
return {
next: () => Number(cin[cid++]),
nextstr: () => cin[cid++],
nextbig: () => BigInt(cin[cid++]),
nexts: (n, addNum = 0, parse = true) =>
parse ? cin.slice(cid, cid += n).map(s => Number(s) + addNum) : cin.slice(cid, cid += n),
nextssort: (n, parse = true, desc = false) =>
parse
? cin.slice(cid, cid += n).map(Number).sort((a, b) => desc ? b - a : a - b)
: cin.slice(cid, cid += n).sort((a, b) => desc ? b.localeCompare(a) : a.localeCompare(b)),
nextm: (h, w, parse = true) => {
const res = []
for (let i = 0; i < h; i++) {
const row = cin.slice(cid, cid += w)
res.push(parse ? row.map(Number) : row)
}
return res
},
xArray: createNDArray,
}
}
if (require.main === module) {
const fs = require('node:fs')
const input = fs.readFileSync('/dev/stdin', 'utf8')
console.log(main(input))
}
module.exports = { main }
Submission Info
| Submission Time |
|
| Task |
C - Bipartize |
| User |
xhksun |
| Language |
JavaScript (Node.js 18.16.1) |
| Score |
350 |
| Code Size |
1863 Byte |
| Status |
AC |
| Exec Time |
227 ms |
| Memory |
48124 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
350 / 350 |
| Status |
|
|
| 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 |
38 ms |
42756 KiB |
| 00_sample_01.txt |
AC |
38 ms |
42596 KiB |
| 00_sample_02.txt |
AC |
227 ms |
47968 KiB |
| 01_random_03.txt |
AC |
38 ms |
42844 KiB |
| 01_random_04.txt |
AC |
40 ms |
43864 KiB |
| 01_random_05.txt |
AC |
39 ms |
42796 KiB |
| 01_random_06.txt |
AC |
38 ms |
42892 KiB |
| 01_random_07.txt |
AC |
40 ms |
44180 KiB |
| 01_random_08.txt |
AC |
38 ms |
42996 KiB |
| 01_random_09.txt |
AC |
39 ms |
43220 KiB |
| 01_random_10.txt |
AC |
39 ms |
43168 KiB |
| 01_random_11.txt |
AC |
39 ms |
43628 KiB |
| 01_random_12.txt |
AC |
46 ms |
48016 KiB |
| 01_random_13.txt |
AC |
46 ms |
48012 KiB |
| 01_random_14.txt |
AC |
46 ms |
48124 KiB |
| 01_random_15.txt |
AC |
45 ms |
48032 KiB |
| 01_random_16.txt |
AC |
45 ms |
48060 KiB |
| 01_random_17.txt |
AC |
38 ms |
42968 KiB |
| 01_random_18.txt |
AC |
38 ms |
42896 KiB |
| 01_random_19.txt |
AC |
39 ms |
42904 KiB |
| 01_random_20.txt |
AC |
38 ms |
43164 KiB |
| 01_random_21.txt |
AC |
38 ms |
42784 KiB |
| 01_random_22.txt |
AC |
38 ms |
42800 KiB |
| 01_random_23.txt |
AC |
38 ms |
42696 KiB |
| 01_random_24.txt |
AC |
38 ms |
42784 KiB |