wildcatco / boj-helper Goto Github PK
View Code? Open in Web Editor NEW백준 문제를 푸는데 도움을 주는 사이트입니다
Home Page: https://boj-helper.vercel.app
백준 문제를 푸는데 도움을 주는 사이트입니다
Home Page: https://boj-helper.vercel.app
로그인이 안됩니다..!
문제 11725 번을 푸는 중에 이슈가 있습니다
백준에서 통과하는 코드인데 BOJ helper 에서 에러가 발생하네요
아래는 에러 재현을 위한 코드입니다
// 입력을 받아오기 위해 아래 두줄의 코드를 사용하세요. (수정 금지)
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'));
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;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.