Submission #74599393


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 now = Array.from({length: m}, () => 0)
  const next1 =  Array.from({length: m}, () => 0)
  for (let i = 0; i < n; i++) {
    const [a, b] = nexts(2)
    now[a - 1]++
    next1[b - 1]++
  }
  const res = []
  for (let i = 0; i < m; i++) {
    res.push(next1[i] - now[i])
  }
  return res.join('\n')
}
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 B - Personnel Change
User xhksun
Language JavaScript (Node.js 22.19.0)
Score 200
Code Size 1797 Byte
Status AC
Exec Time 40 ms
Memory 42036 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 11
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_small_m_random_01.txt, 01_small_m_random_02.txt, 01_small_m_random_03.txt, 02_large_m_random_01.txt, 02_large_m_random_02.txt, 02_large_m_random_03.txt, 03_large_m_biased_01.txt, 03_large_m_biased_02.txt, 03_large_m_biased_03.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 40 ms 41964 KiB
00_sample_02.txt AC 22 ms 41780 KiB
01_small_m_random_01.txt AC 23 ms 41852 KiB
01_small_m_random_02.txt AC 22 ms 41952 KiB
01_small_m_random_03.txt AC 22 ms 42032 KiB
02_large_m_random_01.txt AC 23 ms 42036 KiB
02_large_m_random_02.txt AC 22 ms 41828 KiB
02_large_m_random_03.txt AC 21 ms 41828 KiB
03_large_m_biased_01.txt AC 22 ms 41900 KiB
03_large_m_biased_02.txt AC 21 ms 41892 KiB
03_large_m_biased_03.txt AC 20 ms 41952 KiB