백준 2866 nodejs

윤익·2022년 11월 2일
0

https://www.acmicpc.net/problem/2866

const fs = require('fs')
const input = fs.readFileSync('/dev/stdin').toString().trim().split('\n')
const [R, C] = input[0].split(' ').map(Number)
const A = new Array(C).fill('')
for (let i = 0; i < C; i++) for (let j = 1; j <= R; j++) A[i] += input[j][i]
let [first, last] = [1, R]
while (first <= last) {
  const mid = Math.ceil((first + last) / 2)
  const B = new Set(A.map(e => e.slice(mid)))
  B.size == C ? (first = mid + 1) : (last = mid - 1)
}
console.log(last)
profile
https://nickyoon.tistory.com/ 기술 블로그 이전

0개의 댓글