Giter VIP home page Giter VIP logo

boj-helper's Introduction

Hi there 👋

boj-helper's People

Contributors

wildcatco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

2wheeh

boj-helper's Issues

글로벌 스코프에 return 이 있는 경우 에러

4158 번 풀이 중 에러가 발생하네요 ~

syntaxerror return outside function 에러입니다

에러 발생 코드

// 입력을 받아오기 위해 아래 두줄의 코드를 사용하세요. (수정 금지)
const fs = require('fs');
const stdin = fs.readFileSync('/dev/stdin').toString().trim();


const inputs = stdin.split('/\r?\n/');

const biSearch = (arr, target) => {
  let s = 0;
  let e = arr.length;
  let m;

  while (s <= e) {
    m = Math.floor((s + e) / 2);

    if (arr[m] === target) return true;

    if (+arr[m] < +target) s = m + 1;
    else e = m - 1;
  }

  return false;
};

function solution(longer, shorter) {
  let count = 0;

  shorter.forEach(n => {
    if (biSearch(longer, n)) count += 1;
  });

  return count;
}

let tcIndex = 0;
while (true) {
  const [N, M] = inputs[tcIndex + 0].split(' ').map(v => +v);
  if (N === 0 && M === 0) return;

  const cdOnBoy = inputs.slice(tcIndex + 1, tcIndex + N + 1);
  const cdOnGirl = inputs.slice(tcIndex + N + 1, tcIndex + N + M + 1);

  if (N >= M) console.log(solution(cdOnBoy, cdOnGirl));
  else console.log(solution(cdOnGirl, cdOnBoy));

  tcIndex += N + M + 1;
}

SyntaxError: No identifiers allowed directly after numeric literal

문제 11725 번을 푸는 중에 이슈가 있습니다
백준에서 통과하는 코드인데 BOJ helper 에서 에러가 발생하네요

image

아래는 에러 재현을 위한 코드입니다

// 입력을 받아오기 위해 아래 두줄의 코드를 사용하세요. (수정 금지)
const fs = require('fs');
const stdin = fs.readFileSync('/dev/stdin').toString().trim();

const inputs = stdin.split('\n');
const N = +inputs[0];
const tree = new Map();

for (let i = 1; i < N; i++) {
  const [v, u] = inputs[i].split(' ').map(Number);

  if (!tree.has(v)) tree.set(v, []);
  if (!tree.has(u)) tree.set(u, []);

  tree.get(v).push(u);
  tree.get(u).push(v);
}

const parent = Array.from(Array(N + 1).fill(0));

const stack = [1];
parent[1] = 1;

while (stack.length > 0) {
  const src = stack.pop();
  for (const dest of tree.get(src)) {
    if (parent[dest] === 0) {
      parent[dest] = src;
      stack.push(dest);
    }
  }
}

console.log(parent.slice(2).join('\n'));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.