diff --git a/.github/get_problem/main.js b/.github/get_problem/main.js index cdfd0c6..0a10d33 100644 --- a/.github/get_problem/main.js +++ b/.github/get_problem/main.js @@ -1,73 +1,57 @@ -const axios = require('axios'); -const cheerio = require('cheerio'); -const { Octokit } = require('@octokit/core'); +import axios from "axios"; +import {Octokit} from "octokit"; +import * as cheerio from "cheerio"; async function getProblemUrl() { - try { - const response = await axios.get('https://solved.ac/search?query=*g5..g3+s%23100..+%21%23math+%21%23geometry+%21%23number_theory+%21%40kjhonggg+%21%40ddingmin+%21%40dydwo0740+%21%40inbloom+%21%40pon06061&sort=random&direction=asc&page=1'); + const response = await axios.get('https://solved.ac/search?query=*g3..p5+s%23200..+%21%23math+%21%23geometry+%21%23number_theory+%21%40dydwo0740+%21%40inbloom+w%3Ffalse+%25ko&sort=random&direction=asc&page=1'); const html = response.data; const $ = cheerio.load(html); + const problemId = $('#__next > div.css-1shh4uc > div:nth-child(4) > div.css-qijqp5 > table > tbody > tr:nth-child(2) > td:nth-child(1) > div > div > div > span > span > a').text(); + if (!problemId) { + throw new Error('Failed to fetch the problem URL'); + } - const elementContent = $('#__next > div > div:nth-child(4) > div.css-qijqp5 > table > tbody > tr:nth-child(2) > td:nth-child(1) > div > div > div > span > a > span').text(); - - return `https://www.acmicpc.net/problem/${elementContent}`; - } catch (error) { - throw new Error('Failed to fetch the problem URL'); - } + console.log('Got problem id: ', problemId) + return `https://www.acmicpc.net/problem/${problemId}`; } async function createGitHubIssue(url) { - try { - const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN }); + const octokit = new Octokit({auth: process.env.GITHUB_TOKEN}); const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); const today = new Date(); - const options = { timeZone: 'Asia/Seoul', year: 'numeric', month: '2-digit', day: '2-digit' }; + const options = {timeZone: 'Asia/Seoul', year: 'numeric', month: '2-digit', day: '2-digit'}; const dateFormatter = new Intl.DateTimeFormat('ko-KR', options); const formattedDate = dateFormatter.format(today); const issueResponse = await octokit.request('POST /repos/:owner/:repo/issues', { - owner, - repo, - title: formattedDate, - body: url, + owner, + repo, + title: formattedDate, + body: url, }); - console.log('GitHub Issue created:', issueResponse.data.html_url); - } catch (error) { - console.error('Error creating GitHub Issue:', error.message); - } } async function sendDiscordMessage(messageContent) { - try { const webhookUrl = process.env.DISCORD_ALGO; const message = { - content: messageContent, - username: '오늘의 알고리즘', + content: messageContent, + username: '오늘의 알고리즘', }; const response = await axios.post(webhookUrl, message); console.log('Discord message sent successfully:', response.data); - } catch (error) { - console.error('Error sending Discord message:', error.message); - } -} - -async function run() { - try { - const problemUrl = await getProblemUrl(); - const formattedDate = new Intl.DateTimeFormat('ko-KR', { timeZone: 'Asia/Seoul', year: 'numeric', month: '2-digit', day: '2-digit' }).format(new Date()); - - // GitHub Issue 생성 - await createGitHubIssue(problemUrl); - - // Discord 메시지 전송 - const discordMessageContent = `${formattedDate}\n${problemUrl}`; - await sendDiscordMessage(discordMessageContent); - } catch (error) { - console.error('Error:', error.message); - } } -run(); +const formattedDate = new Intl.DateTimeFormat('ko-KR', { + timeZone: 'Asia/Seoul', + year: 'numeric', + month: '2-digit', + day: '2-digit' +}).format(new Date()); + +const problemUrl = await getProblemUrl(); +console.log(problemUrl) +await createGitHubIssue(problemUrl); +await sendDiscordMessage(`${formattedDate}\n${problemUrl}`); diff --git a/.github/get_problem/package-lock.json b/.github/get_problem/package-lock.json index 319a039..fb1eb35 100644 --- a/.github/get_problem/package-lock.json +++ b/.github/get_problem/package-lock.json @@ -9,370 +9,345 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "axios": "^1.6.2", + "axios": "^1.7.2", "cheerio": "^1.0.0-rc.12", - "octokit": "^3.1.2" + "octokit": "^4.0.2" } }, "node_modules/@octokit/app": { - "version": "14.0.2", - "resolved": "https://registry.npmjs.org/@octokit/app/-/app-14.0.2.tgz", - "integrity": "sha512-NCSCktSx+XmjuSUVn2dLfqQ9WIYePGP95SDJs4I9cn/0ZkeXcPkaoCLl64Us3dRKL2ozC7hArwze5Eu+/qt1tg==", + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/@octokit/app/-/app-15.1.0.tgz", + "integrity": "sha512-TkBr7QgOmE6ORxvIAhDbZsqPkF7RSqTY4pLTtUQCvr6dTXqvi2fFo46q3h1lxlk/sGMQjqyZ0kEahkD/NyzOHg==", "dependencies": { - "@octokit/auth-app": "^6.0.0", - "@octokit/auth-unauthenticated": "^5.0.0", - "@octokit/core": "^5.0.0", - "@octokit/oauth-app": "^6.0.0", - "@octokit/plugin-paginate-rest": "^9.0.0", - "@octokit/types": "^12.0.0", - "@octokit/webhooks": "^12.0.4" + "@octokit/auth-app": "^7.0.0", + "@octokit/auth-unauthenticated": "^6.0.0", + "@octokit/core": "^6.1.2", + "@octokit/oauth-app": "^7.0.0", + "@octokit/plugin-paginate-rest": "^11.0.0", + "@octokit/types": "^13.0.0", + "@octokit/webhooks": "^13.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/auth-app": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-6.0.2.tgz", - "integrity": "sha512-HYuRX3Fvhs2y9i7a4F8f+A5HWfacRWmpERHGBEOtgvKVjJkOQZKUY2v6HiSszYecHAF8Ojqngp2iraSP3SvNpQ==", - "dependencies": { - "@octokit/auth-oauth-app": "^7.0.0", - "@octokit/auth-oauth-user": "^4.0.0", - "@octokit/request": "^8.0.2", - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^12.0.0", - "deprecation": "^2.3.1", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-7.1.0.tgz", + "integrity": "sha512-cazGaJPSgeZ8NkVYeM/C5l/6IQ5vZnsI8p1aMucadCkt/bndI+q+VqwrlnWbASRmenjOkf1t1RpCKrif53U8gw==", + "dependencies": { + "@octokit/auth-oauth-app": "^8.1.0", + "@octokit/auth-oauth-user": "^5.1.0", + "@octokit/request": "^9.1.1", + "@octokit/request-error": "^6.1.1", + "@octokit/types": "^13.4.1", "lru-cache": "^10.0.0", - "universal-github-app-jwt": "^1.1.1", - "universal-user-agent": "^6.0.0" + "universal-github-app-jwt": "^2.2.0", + "universal-user-agent": "^7.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/auth-oauth-app": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-app/-/auth-oauth-app-7.0.1.tgz", - "integrity": "sha512-RE0KK0DCjCHXHlQBoubwlLijXEKfhMhKm9gO56xYvFmP1QTMb+vvwRPmQLLx0V+5AvV9N9I3lr1WyTzwL3rMDg==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-app/-/auth-oauth-app-8.1.1.tgz", + "integrity": "sha512-5UtmxXAvU2wfcHIPPDWzVSAWXVJzG3NWsxb7zCFplCWEmMCArSZV0UQu5jw5goLQXbFyOr5onzEH37UJB3zQQg==", "dependencies": { - "@octokit/auth-oauth-device": "^6.0.0", - "@octokit/auth-oauth-user": "^4.0.0", - "@octokit/request": "^8.0.2", - "@octokit/types": "^12.0.0", - "@types/btoa-lite": "^1.0.0", - "btoa-lite": "^1.0.0", - "universal-user-agent": "^6.0.0" + "@octokit/auth-oauth-device": "^7.0.0", + "@octokit/auth-oauth-user": "^5.0.1", + "@octokit/request": "^9.0.0", + "@octokit/types": "^13.0.0", + "universal-user-agent": "^7.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/auth-oauth-device": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-device/-/auth-oauth-device-6.0.1.tgz", - "integrity": "sha512-yxU0rkL65QkjbqQedgVx3gmW7YM5fF+r5uaSj9tM/cQGVqloXcqP2xK90eTyYvl29arFVCW8Vz4H/t47mL0ELw==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-device/-/auth-oauth-device-7.1.1.tgz", + "integrity": "sha512-HWl8lYueHonuyjrKKIup/1tiy0xcmQCdq5ikvMO1YwkNNkxb6DXfrPjrMYItNLyCP/o2H87WuijuE+SlBTT8eg==", "dependencies": { - "@octokit/oauth-methods": "^4.0.0", - "@octokit/request": "^8.0.0", - "@octokit/types": "^12.0.0", - "universal-user-agent": "^6.0.0" + "@octokit/oauth-methods": "^5.0.0", + "@octokit/request": "^9.0.0", + "@octokit/types": "^13.0.0", + "universal-user-agent": "^7.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/auth-oauth-user": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-user/-/auth-oauth-user-4.0.1.tgz", - "integrity": "sha512-N94wWW09d0hleCnrO5wt5MxekatqEJ4zf+1vSe8MKMrhZ7gAXKFOKrDEZW2INltvBWJCyDUELgGRv8gfErH1Iw==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-user/-/auth-oauth-user-5.1.1.tgz", + "integrity": "sha512-rRkMz0ErOppdvEfnemHJXgZ9vTPhBuC6yASeFaB7I2yLMd7QpjfrL1mnvRPlyKo+M6eeLxrKanXJ9Qte29SRsw==", "dependencies": { - "@octokit/auth-oauth-device": "^6.0.0", - "@octokit/oauth-methods": "^4.0.0", - "@octokit/request": "^8.0.2", - "@octokit/types": "^12.0.0", - "btoa-lite": "^1.0.0", - "universal-user-agent": "^6.0.0" + "@octokit/auth-oauth-device": "^7.0.1", + "@octokit/oauth-methods": "^5.0.0", + "@octokit/request": "^9.0.1", + "@octokit/types": "^13.0.0", + "universal-user-agent": "^7.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/auth-token": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz", - "integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-5.1.1.tgz", + "integrity": "sha512-rh3G3wDO8J9wSjfI436JUKzHIxq8NaiL0tVeB2aXmG6p/9859aUOAjA9pmSPNGGZxfwmaJ9ozOJImuNVJdpvbA==", "engines": { "node": ">= 18" } }, "node_modules/@octokit/auth-unauthenticated": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@octokit/auth-unauthenticated/-/auth-unauthenticated-5.0.1.tgz", - "integrity": "sha512-oxeWzmBFxWd+XolxKTc4zr+h3mt+yofn4r7OfoIkR/Cj/o70eEGmPsFbueyJE2iBAGpjgTnEOKM3pnuEGVmiqg==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-unauthenticated/-/auth-unauthenticated-6.1.0.tgz", + "integrity": "sha512-zPSmfrUAcspZH/lOFQnVnvjQZsIvmfApQH6GzJrkIunDooU1Su2qt2FfMTSVPRp7WLTQyC20Kd55lF+mIYaohQ==", "dependencies": { - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^12.0.0" + "@octokit/request-error": "^6.0.1", + "@octokit/types": "^13.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/core": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.2.tgz", - "integrity": "sha512-cZUy1gUvd4vttMic7C0lwPed8IYXWYp8kHIMatyhY8t8n3Cpw2ILczkV5pGMPqef7v0bLo0pOHrEHarsau2Ydg==", + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-6.1.2.tgz", + "integrity": "sha512-hEb7Ma4cGJGEUNOAVmyfdB/3WirWMg5hDuNFVejGEDFqupeOysLc2sG6HJxY2etBp5YQu5Wtxwi020jS9xlUwg==", "dependencies": { - "@octokit/auth-token": "^4.0.0", - "@octokit/graphql": "^7.0.0", - "@octokit/request": "^8.0.2", - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^12.0.0", - "before-after-hook": "^2.2.0", - "universal-user-agent": "^6.0.0" + "@octokit/auth-token": "^5.0.0", + "@octokit/graphql": "^8.0.0", + "@octokit/request": "^9.0.0", + "@octokit/request-error": "^6.0.1", + "@octokit/types": "^13.0.0", + "before-after-hook": "^3.0.2", + "universal-user-agent": "^7.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/endpoint": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.4.tgz", - "integrity": "sha512-DWPLtr1Kz3tv8L0UvXTDP1fNwM0S+z6EJpRcvH66orY6Eld4XBMCSYsaWp4xIm61jTWxK68BrR7ibO+vSDnZqw==", + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.1.1.tgz", + "integrity": "sha512-JYjh5rMOwXMJyUpj028cu0Gbp7qe/ihxfJMLc8VZBMMqSwLgOxDI1911gV4Enl1QSavAQNJcwmwBF9M0VvLh6Q==", "dependencies": { - "@octokit/types": "^12.0.0", - "universal-user-agent": "^6.0.0" + "@octokit/types": "^13.0.0", + "universal-user-agent": "^7.0.2" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/graphql": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.0.2.tgz", - "integrity": "sha512-OJ2iGMtj5Tg3s6RaXH22cJcxXRi7Y3EBqbHTBRq+PQAqfaS8f/236fUrWhfSn8P4jovyzqucxme7/vWSSZBX2Q==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-8.1.1.tgz", + "integrity": "sha512-ukiRmuHTi6ebQx/HFRCXKbDlOh/7xEV6QUXaE7MJEKGNAncGI/STSbOkl12qVXZrfZdpXctx5O9X1AIaebiDBg==", "dependencies": { - "@octokit/request": "^8.0.1", - "@octokit/types": "^12.0.0", - "universal-user-agent": "^6.0.0" + "@octokit/request": "^9.0.0", + "@octokit/types": "^13.0.0", + "universal-user-agent": "^7.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/oauth-app": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@octokit/oauth-app/-/oauth-app-6.0.0.tgz", - "integrity": "sha512-bNMkS+vJ6oz2hCyraT9ZfTpAQ8dZNqJJQVNaKjPLx4ue5RZiFdU1YWXguOPR8AaSHS+lKe+lR3abn2siGd+zow==", - "dependencies": { - "@octokit/auth-oauth-app": "^7.0.0", - "@octokit/auth-oauth-user": "^4.0.0", - "@octokit/auth-unauthenticated": "^5.0.0", - "@octokit/core": "^5.0.0", - "@octokit/oauth-authorization-url": "^6.0.2", - "@octokit/oauth-methods": "^4.0.0", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@octokit/oauth-app/-/oauth-app-7.1.3.tgz", + "integrity": "sha512-EHXbOpBkSGVVGF1W+NLMmsnSsJRkcrnVmDKt0TQYRBb6xWfWzoi9sBD4DIqZ8jGhOWO/V8t4fqFyJ4vDQDn9bg==", + "dependencies": { + "@octokit/auth-oauth-app": "^8.0.0", + "@octokit/auth-oauth-user": "^5.0.1", + "@octokit/auth-unauthenticated": "^6.0.0-beta.1", + "@octokit/core": "^6.0.0", + "@octokit/oauth-authorization-url": "^7.0.0", + "@octokit/oauth-methods": "^5.0.0", "@types/aws-lambda": "^8.10.83", - "universal-user-agent": "^6.0.0" + "universal-user-agent": "^7.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/oauth-authorization-url": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-6.0.2.tgz", - "integrity": "sha512-CdoJukjXXxqLNK4y/VOiVzQVjibqoj/xHgInekviUJV73y/BSIcwvJ/4aNHPBPKcPWFnd4/lO9uqRV65jXhcLA==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-7.1.1.tgz", + "integrity": "sha512-ooXV8GBSabSWyhLUowlMIVd9l1s2nsOGQdlP2SQ4LnkEsGXzeCvbSbCPdZThXhEFzleGPwbapT0Sb+YhXRyjCA==", "engines": { "node": ">= 18" } }, "node_modules/@octokit/oauth-methods": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@octokit/oauth-methods/-/oauth-methods-4.0.1.tgz", - "integrity": "sha512-1NdTGCoBHyD6J0n2WGXg9+yDLZrRNZ0moTEex/LSPr49m530WNKcCfXDghofYptr3st3eTii+EHoG5k/o+vbtw==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@octokit/oauth-methods/-/oauth-methods-5.1.2.tgz", + "integrity": "sha512-C5lglRD+sBlbrhCUTxgJAFjWgJlmTx5bQ7Ch0+2uqRjYv7Cfb5xpX4WuSC9UgQna3sqRGBL9EImX9PvTpMaQ7g==", "dependencies": { - "@octokit/oauth-authorization-url": "^6.0.2", - "@octokit/request": "^8.0.2", - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^12.0.0", - "btoa-lite": "^1.0.0" + "@octokit/oauth-authorization-url": "^7.0.0", + "@octokit/request": "^9.1.0", + "@octokit/request-error": "^6.1.0", + "@octokit/types": "^13.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/openapi-types": { - "version": "19.1.0", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-19.1.0.tgz", - "integrity": "sha512-6G+ywGClliGQwRsjvqVYpklIfa7oRPA0vyhPQG/1Feh+B+wU0vGH1JiJ5T25d3g1JZYBHzR2qefLi9x8Gt+cpw==" + "version": "22.2.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-22.2.0.tgz", + "integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg==" + }, + "node_modules/@octokit/openapi-webhooks-types": { + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/@octokit/openapi-webhooks-types/-/openapi-webhooks-types-8.2.1.tgz", + "integrity": "sha512-msAU1oTSm0ZmvAE0xDemuF4tVs5i0xNnNGtNmr4EuATi+1Rn8cZDetj6NXioSf5LwnxEc209COa/WOSbjuhLUA==" }, "node_modules/@octokit/plugin-paginate-graphql": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-graphql/-/plugin-paginate-graphql-4.0.0.tgz", - "integrity": "sha512-7HcYW5tP7/Z6AETAPU14gp5H5KmCPT3hmJrS/5tO7HIgbwenYmgw4OY9Ma54FDySuxMwD+wsJlxtuGWwuZuItA==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-graphql/-/plugin-paginate-graphql-5.2.2.tgz", + "integrity": "sha512-7znSVvlNAOJisCqAnjN1FtEziweOHSjPGAuc5W58NeGNAr/ZB57yCsjQbXDlWsVryA7hHQaEQPcBbJYFawlkyg==", "engines": { "node": ">= 18" }, "peerDependencies": { - "@octokit/core": ">=5" + "@octokit/core": ">=6" } }, "node_modules/@octokit/plugin-paginate-rest": { - "version": "9.1.5", - "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.1.5.tgz", - "integrity": "sha512-WKTQXxK+bu49qzwv4qKbMMRXej1DU2gq017euWyKVudA6MldaSSQuxtz+vGbhxV4CjxpUxjZu6rM2wfc1FiWVg==", + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.3.0.tgz", + "integrity": "sha512-n4znWfRinnUQF6TPyxs7EctSAA3yVSP4qlJP2YgI3g9d4Ae2n5F3XDOjbUluKRxPU3rfsgpOboI4O4VtPc6Ilg==", "dependencies": { - "@octokit/types": "^12.4.0" + "@octokit/types": "^13.5.0" }, "engines": { "node": ">= 18" }, "peerDependencies": { - "@octokit/core": ">=5" + "@octokit/core": ">=6" } }, "node_modules/@octokit/plugin-rest-endpoint-methods": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.2.0.tgz", - "integrity": "sha512-ePbgBMYtGoRNXDyKGvr9cyHjQ163PbwD0y1MkDJCpkO2YH4OeXX40c4wYHKikHGZcpGPbcRLuy0unPUuafco8Q==", + "version": "13.2.1", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-13.2.1.tgz", + "integrity": "sha512-YMWBw6Exh1ZBs5cCE0AnzYxSQDIJS00VlBqISTgNYmu5MBdeM07K/MAJjy/VkNaH5jpJmD/5HFUvIZ+LDB5jSQ==", "dependencies": { - "@octokit/types": "^12.3.0" + "@octokit/types": "^13.5.0" }, "engines": { "node": ">= 18" }, "peerDependencies": { - "@octokit/core": ">=5" + "@octokit/core": ">=6" } }, "node_modules/@octokit/plugin-retry": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-6.0.1.tgz", - "integrity": "sha512-SKs+Tz9oj0g4p28qkZwl/topGcb0k0qPNX/i7vBKmDsjoeqnVfFUquqrE/O9oJY7+oLzdCtkiWSXLpLjvl6uog==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-7.1.1.tgz", + "integrity": "sha512-G9Ue+x2odcb8E1XIPhaFBnTTIrrUDfXN05iFXiqhR+SeeeDMMILcAnysOsxUpEWcQp2e5Ft397FCXTcPkiPkLw==", "dependencies": { - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^12.0.0", + "@octokit/request-error": "^6.0.0", + "@octokit/types": "^13.0.0", "bottleneck": "^2.15.3" }, "engines": { "node": ">= 18" }, "peerDependencies": { - "@octokit/core": ">=5" + "@octokit/core": ">=6" } }, "node_modules/@octokit/plugin-throttling": { - "version": "8.1.3", - "resolved": "https://registry.npmjs.org/@octokit/plugin-throttling/-/plugin-throttling-8.1.3.tgz", - "integrity": "sha512-pfyqaqpc0EXh5Cn4HX9lWYsZ4gGbjnSmUILeu4u2gnuM50K/wIk9s1Pxt3lVeVwekmITgN/nJdoh43Ka+vye8A==", + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-throttling/-/plugin-throttling-9.3.0.tgz", + "integrity": "sha512-B5YTToSRTzNSeEyssnrT7WwGhpIdbpV9NKIs3KyTWHX6PhpYn7gqF/+lL3BvsASBM3Sg5BAUYk7KZx5p/Ec77w==", "dependencies": { - "@octokit/types": "^12.2.0", + "@octokit/types": "^13.0.0", "bottleneck": "^2.15.3" }, "engines": { "node": ">= 18" }, "peerDependencies": { - "@octokit/core": "^5.0.0" + "@octokit/core": "^6.0.0" } }, "node_modules/@octokit/request": { - "version": "8.1.6", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.1.6.tgz", - "integrity": "sha512-YhPaGml3ncZC1NfXpP3WZ7iliL1ap6tLkAp6MvbK2fTTPytzVUyUesBBogcdMm86uRYO5rHaM1xIWxigWZ17MQ==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.1.1.tgz", + "integrity": "sha512-pyAguc0p+f+GbQho0uNetNQMmLG1e80WjkIaqqgUkihqUp0boRU6nKItXO4VWnr+nbZiLGEyy4TeKRwqaLvYgw==", "dependencies": { - "@octokit/endpoint": "^9.0.0", - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^12.0.0", - "universal-user-agent": "^6.0.0" + "@octokit/endpoint": "^10.0.0", + "@octokit/request-error": "^6.0.1", + "@octokit/types": "^13.1.0", + "universal-user-agent": "^7.0.2" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/request-error": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz", - "integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.1.1.tgz", + "integrity": "sha512-1mw1gqT3fR/WFvnoVpY/zUM2o/XkMs/2AszUUG9I69xn0JFLv6PGkPhNk5lbfvROs79wiS0bqiJNxfCZcRJJdg==", "dependencies": { - "@octokit/types": "^12.0.0", - "deprecation": "^2.0.0", - "once": "^1.4.0" + "@octokit/types": "^13.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/types": { - "version": "12.4.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.4.0.tgz", - "integrity": "sha512-FLWs/AvZllw/AGVs+nJ+ELCDZZJk+kY0zMen118xhL2zD0s1etIUHm1odgjP7epxYU1ln7SZxEUWYop5bhsdgQ==", + "version": "13.5.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.5.0.tgz", + "integrity": "sha512-HdqWTf5Z3qwDVlzCrP8UJquMwunpDiMPt5er+QjGzL4hqr/vBVY/MauQgS1xWxCDT1oMx1EULyqxncdCY/NVSQ==", "dependencies": { - "@octokit/openapi-types": "^19.1.0" + "@octokit/openapi-types": "^22.2.0" } }, "node_modules/@octokit/webhooks": { - "version": "12.0.10", - "resolved": "https://registry.npmjs.org/@octokit/webhooks/-/webhooks-12.0.10.tgz", - "integrity": "sha512-Q8d26l7gZ3L1SSr25NFbbP0B431sovU5r0tIqcvy8Z4PrD1LBv0cJEjvDLOieouzPSTzSzufzRIeXD7S+zAESA==", + "version": "13.2.7", + "resolved": "https://registry.npmjs.org/@octokit/webhooks/-/webhooks-13.2.7.tgz", + "integrity": "sha512-sPHCyi9uZuCs1gg0yF53FFocM+GsiiBEhQQV/itGzzQ8gjyv2GMJ1YvgdDY4lC0ePZeiV3juEw4GbS6w1VHhRw==", "dependencies": { - "@octokit/request-error": "^5.0.0", - "@octokit/webhooks-methods": "^4.0.0", - "@octokit/webhooks-types": "7.1.0", - "aggregate-error": "^3.1.0" + "@octokit/openapi-webhooks-types": "8.2.1", + "@octokit/request-error": "^6.0.1", + "@octokit/webhooks-methods": "^5.0.0", + "aggregate-error": "^5.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/webhooks-methods": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@octokit/webhooks-methods/-/webhooks-methods-4.0.0.tgz", - "integrity": "sha512-M8mwmTXp+VeolOS/kfRvsDdW+IO0qJ8kYodM/sAysk093q6ApgmBXwK1ZlUvAwXVrp/YVHp6aArj4auAxUAOFw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@octokit/webhooks-methods/-/webhooks-methods-5.1.0.tgz", + "integrity": "sha512-yFZa3UH11VIxYnnoOYCVoJ3q4ChuSOk2IVBBQ0O3xtKX4x9bmKb/1t+Mxixv2iUhzMdOl1qeWJqEhouXXzB3rQ==", "engines": { "node": ">= 18" } }, - "node_modules/@octokit/webhooks-types": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@octokit/webhooks-types/-/webhooks-types-7.1.0.tgz", - "integrity": "sha512-y92CpG4kFFtBBjni8LHoV12IegJ+KFxLgKRengrVjKmGE5XMeCuGvlfRe75lTRrgXaG6XIWJlFpIDTlkoJsU8w==" - }, "node_modules/@types/aws-lambda": { - "version": "8.10.130", - "resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.130.tgz", - "integrity": "sha512-HxTfLeGvD1wTJqIGwcBCpNmHKenja+We1e0cuzeIDFfbEj3ixnlTInyPR/81zAe0Ss/Ip12rFK6XNeMLVucOSg==" - }, - "node_modules/@types/btoa-lite": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@types/btoa-lite/-/btoa-lite-1.0.2.tgz", - "integrity": "sha512-ZYbcE2x7yrvNFJiU7xJGrpF/ihpkM7zKgw8bha3LNJSesvTtUNxbpzaT7WXBIryf6jovisrxTBvymxMeLLj1Mg==" - }, - "node_modules/@types/jsonwebtoken": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-9.0.5.tgz", - "integrity": "sha512-VRLSGzik+Unrup6BsouBeHsf4d1hOEgYWTm/7Nmw1sXoN1+tRly/Gy/po3yeahnP4jfnQWWAhQAqcNfH7ngOkA==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/node": { - "version": "20.10.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.5.tgz", - "integrity": "sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==", - "dependencies": { - "undici-types": "~5.26.4" - } + "version": "8.10.140", + "resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.140.tgz", + "integrity": "sha512-4Dh3dk2TUcbdfHrX0Al90mNGJDvA9NBiTQPzbrjGi/dLxzKCGOYgT8YQ47jUKNFALkAJAadifq0pzyjIUlhVhg==" }, "node_modules/aggregate-error": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", - "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-5.0.0.tgz", + "integrity": "sha512-gOsf2YwSlleG6IjRYG2A7k0HmBMEo6qVNk9Bp/EaLgAJT5ngH6PXbqa4ItvnEwCm/velL5jAnQgsHsWnjhGmvw==", "dependencies": { - "clean-stack": "^2.0.0", - "indent-string": "^4.0.0" + "clean-stack": "^5.2.0", + "indent-string": "^5.0.0" }, "engines": { - "node": ">=8" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/asynckit": { @@ -381,19 +356,19 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/axios": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", - "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", "dependencies": { - "follow-redirects": "^1.15.0", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } }, "node_modules/before-after-hook": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", - "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-3.0.2.tgz", + "integrity": "sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A==" }, "node_modules/boolbase": { "version": "1.0.0", @@ -405,16 +380,6 @@ "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", "integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==" }, - "node_modules/btoa-lite": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/btoa-lite/-/btoa-lite-1.0.0.tgz", - "integrity": "sha512-gvW7InbIyF8AicrqWoptdW08pUxuhq8BEgowNajy9RhiE86fmGAGl+bLKo6oB8QP0CkqHLowfN0oJdKC/J6LbA==" - }, - "node_modules/buffer-equal-constant-time": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", - "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" - }, "node_modules/cheerio": { "version": "1.0.0-rc.12", "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", @@ -452,11 +417,17 @@ } }, "node_modules/clean-stack": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", - "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-5.2.0.tgz", + "integrity": "sha512-TyUIUJgdFnCISzG5zu3291TAsE77ddchd0bepon1VVQrKLGKFED4iXFEDQ24mIPdPBbyE16PK3F8MYE1CmcBEQ==", + "dependencies": { + "escape-string-regexp": "5.0.0" + }, "engines": { - "node": ">=6" + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/combined-stream": { @@ -504,11 +475,6 @@ "node": ">=0.4.0" } }, - "node_modules/deprecation": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", - "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" - }, "node_modules/dom-serializer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", @@ -560,14 +526,6 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, - "node_modules/ecdsa-sig-formatter": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", - "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", - "dependencies": { - "safe-buffer": "^5.0.1" - } - }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", @@ -579,10 +537,21 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/escape-string-regexp": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "funding": [ { "type": "individual", @@ -630,92 +599,20 @@ } }, "node_modules/indent-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", - "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz", + "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==", "engines": { - "node": ">=8" - } - }, - "node_modules/jsonwebtoken": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", - "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", - "dependencies": { - "jws": "^3.2.2", - "lodash.includes": "^4.3.0", - "lodash.isboolean": "^3.0.3", - "lodash.isinteger": "^4.0.4", - "lodash.isnumber": "^3.0.3", - "lodash.isplainobject": "^4.0.6", - "lodash.isstring": "^4.0.1", - "lodash.once": "^4.0.0", - "ms": "^2.1.1", - "semver": "^7.5.4" + "node": ">=12" }, - "engines": { - "node": ">=12", - "npm": ">=6" - } - }, - "node_modules/jwa": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", - "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", - "dependencies": { - "buffer-equal-constant-time": "1.0.1", - "ecdsa-sig-formatter": "1.0.11", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/jws": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", - "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", - "dependencies": { - "jwa": "^1.4.1", - "safe-buffer": "^5.0.1" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lodash.includes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", - "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==" - }, - "node_modules/lodash.isboolean": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", - "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==" - }, - "node_modules/lodash.isinteger": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", - "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==" - }, - "node_modules/lodash.isnumber": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", - "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==" - }, - "node_modules/lodash.isplainobject": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" - }, - "node_modules/lodash.isstring": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" - }, - "node_modules/lodash.once": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", - "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" - }, "node_modules/lru-cache": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.1.0.tgz", - "integrity": "sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz", + "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", "engines": { "node": "14 || >=16.14" } @@ -739,11 +636,6 @@ "node": ">= 0.6" } }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" - }, "node_modules/nth-check": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", @@ -756,33 +648,25 @@ } }, "node_modules/octokit": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/octokit/-/octokit-3.1.2.tgz", - "integrity": "sha512-MG5qmrTL5y8KYwFgE1A4JWmgfQBaIETE/lOlfwNYx1QOtCQHGVxkRJmdUJltFc1HVn73d61TlMhMyNTOtMl+ng==", - "dependencies": { - "@octokit/app": "^14.0.2", - "@octokit/core": "^5.0.0", - "@octokit/oauth-app": "^6.0.0", - "@octokit/plugin-paginate-graphql": "^4.0.0", - "@octokit/plugin-paginate-rest": "^9.0.0", - "@octokit/plugin-rest-endpoint-methods": "^10.0.0", - "@octokit/plugin-retry": "^6.0.0", - "@octokit/plugin-throttling": "^8.0.0", - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^12.0.0" + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/octokit/-/octokit-4.0.2.tgz", + "integrity": "sha512-wbqF4uc1YbcldtiBFfkSnquHtECEIpYD78YUXI6ri1Im5OO2NLo6ZVpRdbJpdnpZ05zMrVPssNiEo6JQtea+Qg==", + "dependencies": { + "@octokit/app": "^15.0.0", + "@octokit/core": "^6.0.0", + "@octokit/oauth-app": "^7.0.0", + "@octokit/plugin-paginate-graphql": "^5.0.0", + "@octokit/plugin-paginate-rest": "^11.0.0", + "@octokit/plugin-rest-endpoint-methods": "^13.0.0", + "@octokit/plugin-retry": "^7.0.0", + "@octokit/plugin-throttling": "^9.0.0", + "@octokit/request-error": "^6.0.0", + "@octokit/types": "^13.0.0" }, "engines": { "node": ">= 18" } }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dependencies": { - "wrappy": "1" - } - }, "node_modules/parse5": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", @@ -811,78 +695,15 @@ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/semver/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" - }, "node_modules/universal-github-app-jwt": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-1.1.1.tgz", - "integrity": "sha512-G33RTLrIBMFmlDV4u4CBF7dh71eWwykck4XgaxaIVeZKOYZRAAxvcGMRFTUclVY6xoUPQvO4Ne5wKGxYm/Yy9w==", - "dependencies": { - "@types/jsonwebtoken": "^9.0.0", - "jsonwebtoken": "^9.0.0" - } + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-2.2.0.tgz", + "integrity": "sha512-G5o6f95b5BggDGuUfKDApKaCgNYy2x7OdHY0zSMF081O0EJobw+1130VONhrA7ezGSV2FNOGyM+KQpQZAr9bIQ==" }, "node_modules/universal-user-agent": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", - "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==" - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" - }, - "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz", + "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q==" } } } diff --git a/.github/get_problem/package.json b/.github/get_problem/package.json index 6c95259..98a4ed8 100644 --- a/.github/get_problem/package.json +++ b/.github/get_problem/package.json @@ -1,17 +1,18 @@ { - "name": "automate-getting-problem", - "version": "1.0.0", - "description": "", - "main": "main.js", - "scripts": { - "start": "node main.js" - }, - "author": "", - "license": "ISC", - "dependencies": { - "axios": "^1.6.2", - "cheerio": "^1.0.0-rc.12", - "octokit": "^3.1.2" - } - } + "name": "automate-getting-problem", + "version": "1.0.0", + "description": "", + "main": "main.js", + "scripts": { + "start": "node main.js" + }, + "author": "", + "license": "ISC", + "dependencies": { + "axios": "^1.7.2", + "cheerio": "^1.0.0-rc.12", + "octokit": "^4.0.2" + }, + "type": "module" +} \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index cbf757b..582ba45 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,6 +8,6 @@ ## ⌨️ 코드 -``` +``` python java c++ ``` diff --git a/.github/workflows/get_problem.yml b/.github/workflows/get_problem.yml index 0e6a1de..0d3ffc5 100644 --- a/.github/workflows/get_problem.yml +++ b/.github/workflows/get_problem.yml @@ -6,30 +6,28 @@ on: workflow_dispatch: # 수동으로 Workflow를 실행 jobs: - get_problem_and_create_issue: + create-problem-issue: runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4 + with: + sparse-checkout: | + .github/get_problem - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' - - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - restore-keys: ${{ runner.os }}-npm- + cache: 'npm' + cache-dependency-path: '**/package-lock.json' - name: Install Dependencies - run: npm install + run: npm ci working-directory: .github/get_problem - - name: Get problem and Create GitHub Issue + - name: Run Script run: npm start env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update_readme.yml b/.github/workflows/update_readme.yml new file mode 100644 index 0000000..d687fe4 --- /dev/null +++ b/.github/workflows/update_readme.yml @@ -0,0 +1,27 @@ +name: Update README + +on: + schedule: + - cron: '0 21 * * *' # 한국 시간 기준, 매일 아침 6시에 실행 + workflow_dispatch: # 수동으로 Workflow를 실행 + +jobs: + update-readme: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.10.12 # 원하는 Python 버전 설정 + + - name: Install requests + run: pip install requests + + - name: Run Python Script to Update README + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + run: python script/update_readme.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..25aa05a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +**/*.iml \ No newline at end of file diff --git a/README.md b/README.md index f05bddb..c7bdf39 100644 --- a/README.md +++ b/README.md @@ -5,23 +5,168 @@ solve problem everyday
|
+ + kjhonggg95 + |
+
+ + dydwo0740 + |
+
+ + qsunki + |
+
+ + ddingmin + |
+
+ + kwYoohae + |
||||
| kjhonggg95 | -dydwo0740 | -ajsthfldu | -ddingmin | -|||||
|
+ + Baekjoon + + solved.ac + |
+
+ + Baekjoon + + solved.ac + |
+
+ + Baekjoon + + solved.ac + |
+
+ + Baekjoon + + solved.ac + |
+
+ + Baekjoon + + solved.ac + |
+
map = new HashMap<>(); + static Setvisited = new HashSet<>(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + int K = Integer.parseInt(st.nextToken()); + + int[] seq = new int[N + 1]; + + st = new StringTokenizer(br.readLine()); + + for (int i = 1; i <= N; i++) { + seq[i] = Integer.parseInt(st.nextToken()); + } + + for (int i = 0; i < K; i++) { + st = new StringTokenizer(br.readLine()); + + int size = Integer.parseInt(st.nextToken()); + + int[] index = new int[size]; + + for (int j = 0; j < size; j++) { + index[j] = Integer.parseInt(st.nextToken()); + } + + map.put(i + 1, index); + } + + int answer = bfs(seq); + + bw.write(answer+"\n"); + + bw.flush(); + } + + public static int bfs(int[] seq) { + Queue queue = new LinkedList<>(); + + visited.add(getString(seq)); + queue.add(seq); + int cnt = 0; + + while (!queue.isEmpty()) { + Queue temp = new LinkedList<>(queue); + queue.clear(); + while (!temp.isEmpty()) { + int[] cur = temp.poll(); + + if (isAllSame(cur)) { + return cnt; + } + + for(Map.Entry entry : map.entrySet()) { + int[] add = entry.getValue(); + + int[] index = Arrays.copyOf(cur, cur.length); + + for(int i=0;i list = new ArrayList<>(); + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + + int start = Integer.parseInt(st.nextToken()); + int end = Integer.parseInt(st.nextToken()); + + list.add(new int[]{start, end}); + } + + list.sort(new Comparator () { + @Override + public int compare(int[] o1, int[] o2) { + if (o1[0] == o2[0]) { + return o1[1] - o2[1]; + } + return o1[0] - o2[0]; + } + }); + + PriorityQueue pq = new PriorityQueue<>(); + + pq.add(list.get(0)[1]); + + int max = 1; + int start = list.get(0)[0]; + int end = list.get(0)[1]; + + for (int i = 1; i < N; i++) { + int[] cur = list.get(i); + + while (!pq.isEmpty() && pq.peek() <= cur[0]) { + pq.poll(); + } + + pq.add(cur[1]); + + if (max < pq.size()) { + start = cur[0]; + end = pq.peek(); + max = pq.size(); + } else if (max == pq.size()) { + if (end == cur[0]) { + end = pq.peek(); + } + } + } + + bw.write(max + "\n"); + bw.write(start + " " + end + "\n"); + + bw.flush(); + } + + +} diff --git a/dydwo0740/baekjoon/20924.java b/dydwo0740/baekjoon/20924.java new file mode 100644 index 0000000..2658cd7 --- /dev/null +++ b/dydwo0740/baekjoon/20924.java @@ -0,0 +1,125 @@ +import java.io.*; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.StringTokenizer; + +public class Main { + static class Node { + int v; + int dist; + + public Node(int v, int dist) { + this.v = v; + this.dist = dist; + } + } + + static int N; + static int root; + static int ans = Integer.MIN_VALUE; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + // 우선 기가 노드를 탐색하고 기가 노드에서 루트, 기가 노드에서 dfs로 가장 긴 거리 탐색 + + N = Integer.parseInt(st.nextToken()); + + root = Integer.parseInt(st.nextToken()); + + List [] g = new ArrayList[N + 1]; + + for (int i = 0; i <= N; i++) { + g[i] = new ArrayList<>(); + } + + for (int i = 0; i < N - 1; i++) { + st = new StringTokenizer(br.readLine()); + + int v1 = Integer.parseInt(st.nextToken()); + int v2 = Integer.parseInt(st.nextToken()); + int dist = Integer.parseInt(st.nextToken()); + + g[v1].add(new Node(v2, dist)); + g[v2].add(new Node(v1, dist)); + } + + for (int i = 0; i <= N; i++) { + g[i].sort(new Comparator () { + @Override + public int compare(Node o1, Node o2) { + return o1.v - o2.v; + } + }); + } + + boolean[] visited = new boolean[N + 1]; + int start = findGigaNode(g, root, visited); + //System.out.println("start = " + start); + + dfs(g, visited, 0, start); + bw.write(getHeight(root, start, g) + " " + ans + "\n"); + + bw.flush(); + } + + public static int findGigaNode(List [] g, int root, boolean[] visited) { + while (true) { + visited[root] = true; + int count = 0; + int next = 0; + for (int i = 0; i < g[root].size(); i++) { + if (!visited[g[root].get(i).v]) { + next = g[root].get(i).v; + count++; + } + } + //System.out.println("next = " + next); + if (count >= 2) { + return root; + } + + if(count == 0){ + return root; + } + root = next; + } + } + + public static int getHeight(int start, int end, List [] g) { + boolean[] visited = new boolean[N + 1]; + int sum = 0; + while (true) { + if (start == end) { + return sum; + } + + visited[start] = true; + int next = 0; + + for (int i = 0; i < g[start].size(); i++) { + if (!visited[g[start].get(i).v]) { + next = g[start].get(i).v; + sum += g[start].get(i).dist; + break; + } + } + start = next; + } + } + + public static void dfs(List [] g, boolean[] visited, int depth, int cur) { + visited[cur] = true; + ans = Math.max(ans, depth); + for (int i = 0; i < g[cur].size(); i++) { + if (!visited[g[cur].get(i).v]) { + dfs(g, visited, depth + g[cur].get(i).dist, g[cur].get(i).v); + } + } + } + + +} diff --git a/dydwo0740/baekjoon/2140.java b/dydwo0740/baekjoon/2140.java new file mode 100644 index 0000000..93134a8 --- /dev/null +++ b/dydwo0740/baekjoon/2140.java @@ -0,0 +1,69 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static int[] row = {-1, -1, -1, 0, 0, 1, 1, 1}; + static int[] col = {-1, 0, 1, -1, 1, -1, 0, 1}; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + char[][] board = new char[N][N]; + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + + String str = st.nextToken(); + + for (int j = 0; j < N; j++) { + board[i][j] = str.charAt(j); + } + } + + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (Character.isDigit(board[i][j])) { + changeBoard(board, i, j); + } + } + } + int ans = 0; + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (board[i][j] == '#' || board[i][j] == '*') { + ans++; + } + } + } + bw.write(ans + "\n"); + bw.flush(); + } + + public static void changeBoard(char[][] board, int x, int y) { + int N = board.length; + int cur = board[x][y] - '0'; + + for (int i = 0; i < 8; i++) { + int nx = x + row[i]; + int ny = y + col[i]; + + if (0 <= nx && nx < N && 0 <= ny && ny < N) { + if (board[nx][ny] == '#' && cur > 0) { + board[nx][ny] = '*'; + cur--; + } else if (board[nx][ny] == '*' && cur != 0) { + cur--; + } else if (board[nx][ny] == '#' && cur == 0) { + board[nx][ny] = '-'; + } + } + } + } + + +} diff --git a/dydwo0740/baekjoon/2171.java b/dydwo0740/baekjoon/2171.java new file mode 100644 index 0000000..d27bfcb --- /dev/null +++ b/dydwo0740/baekjoon/2171.java @@ -0,0 +1,83 @@ + +import java.io.*; +import java.util.*; + +public class Main { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + int[] xxx = new int[N]; + int[] yyy = new int[N]; + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + xxx[i] = Integer.parseInt(st.nextToken()); + yyy[i] = Integer.parseInt(st.nextToken()); + } + + int[] x = Arrays.copyOf(xxx, N); + int[] y = Arrays.copyOf(yyy, N); + + boolean[][] isHere = new boolean[5000][5000]; + int[][] loc = new int[N][2]; + + Arrays.sort(x); + Arrays.sort(y); + + for (int i = 0; i < N; i++) { + int nx = lowerBound(x, xxx[i]); + int ny = lowerBound(y, yyy[i]); + + loc[i][0] = nx; + loc[i][1] = ny; + + bw.write(nx + " " + ny + "\n"); + + isHere[nx][ny] = true; + } + + int ans = 0; + + for(int i=0;i map = new HashMap<>(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + String str = st.nextToken(); + + int len = str.length(); + + int[] dp = new int[len]; + + st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + + String sub = st.nextToken(); + int weight = Integer.parseInt(st.nextToken()); + + if (sub.length() < weight) { + map.put(sub, weight); + } + } + + if (map.containsKey(String.valueOf(str.charAt(0)))) { + dp[0] = map.get(String.valueOf(str.charAt(0))); + } else{ + dp[0] = 1; + } + + for (int i = 1; i < len; i++) { + for (int j = 0; j <= i; j++) { + String comp = str.substring(j, i + 1); + int value = map.getOrDefault(comp, comp.length()); + + if (j == 0) { + if (value > dp[i]) { + dp[i] = value; + } + continue; + } + + value += dp[j - 1]; + + if (value > dp[i]) { + dp[i] = value; + } + } + } + + + bw.write(dp[len - 1] + "\n"); + + bw.flush(); + } + + +} diff --git a/dydwo0740/baekjoon/2313.java b/dydwo0740/baekjoon/2313.java new file mode 100644 index 0000000..fb8a16e --- /dev/null +++ b/dydwo0740/baekjoon/2313.java @@ -0,0 +1,80 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static List [] sum; + static int[] length; + static int[][] answer; + + static long ans = 0; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + sum = new ArrayList[N]; + + for (int i = 0; i < N; i++) { + sum[i] = new ArrayList<>(); + } + + length = new int[N]; + + answer = new int[N][2]; + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + int size = Integer.parseInt(st.nextToken()); + length[i] = size; + + st = new StringTokenizer(br.readLine()); + + + int num = Integer.parseInt(st.nextToken()); + sum[i].add(0); + sum[i].add(num); + + for (int j = 1; j < size; j++) { + num = Integer.parseInt(st.nextToken()); + sum[i].add(num + sum[i].get(j)); + } + } + + + + for (int i = 0; i < N; i++) { + int max = Integer.MIN_VALUE; + int left = -1; + int right = -1; + for (int j = 1; j <= length[i]; j++) { + for (int k = j; k <= length[i]; k++) { + if (max < (sum[i].get(k) - sum[i].get(j - 1))) { + left = j; + right = k; + max = sum[i].get(k) - sum[i].get(j - 1); + } else if (max == (sum[i].get(k) - sum[i].get(j - 1)) && (right - left) > (k - j)) { + left = j; + right = k; + } + } + } + + ans += max; + answer[i][0] = left; + answer[i][1] = right; + } + + bw.write(ans+"\n"); + + for (int i = 0; i < N; i++) { + bw.write(answer[i][0] + " " + answer[i][1] + "\n"); + } + + bw.flush(); + } + +} diff --git a/dydwo0740/baekjoon/2370.java b/dydwo0740/baekjoon/2370.java new file mode 100644 index 0000000..bb7c015 --- /dev/null +++ b/dydwo0740/baekjoon/2370.java @@ -0,0 +1,68 @@ +import java.io.*; +import java.util.*; +import java.util.stream.Collectors; + +public class Main { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + + int[][] seq = new int[N][2]; + + List list = new ArrayList<>(); + Set visited = new HashSet (); + + for(int i=0;i set = new HashSet<>(); + + for(int i=0;i list = new ArrayList<>(); + List res = new ArrayList<>(); + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + + long s = Long.parseLong(st.nextToken()); + long e = Long.parseLong(st.nextToken()); + long cost = Long.parseLong(st.nextToken()); + + list.add(new Bus(s, e, cost)); + } + + list.sort(new Comparator () { + @Override + public int compare(Bus o1, Bus o2) { + if (o1.start == o2.start) { + Long.compare(o1.end, o2.end); + } + return Long.compare(o1.start, o2.start); + } + }); + + Bus bus = list.get(0); + + long start = bus.start; + long end = bus.end; + long cost = bus.cost; + boolean flag = false; + + if (N == 1) { + res.add(new Bus(start, end, cost)); + } + + for (int i = 1; i < N; i++) { + Bus cur = list.get(i); + + if (i == N - 1) { + flag = true; + } + + if (cur.start <= end) { + end = Math.max(end, cur.end); + cost = Math.min(cost, cur.cost); + + if (flag) { + res.add(new Bus(start, end, cost)); + } + + continue; + } + + res.add(new Bus(start, end, cost)); + start = cur.start; + end = cur.end; + cost = cur.cost; + + if (flag) { + res.add(new Bus(start, end, cost)); + } + } + + res.sort(new Comparator () { + @Override + public int compare(Bus o1, Bus o2) { + return Long.compare(o1.start, o2.start); + } + }); + + bw.write(res.size() + "\n"); + + for (Bus b : res) { + bw.write(b.start + " " + b.end + " " + b.cost + "\n"); + } + + bw.flush(); + } + + +} diff --git a/dydwo0740/baekjoon/23742.java b/dydwo0740/baekjoon/23742.java new file mode 100644 index 0000000..38e72f2 --- /dev/null +++ b/dydwo0740/baekjoon/23742.java @@ -0,0 +1,54 @@ + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.PriorityQueue; +import java.util.StringTokenizer; + +public class Main { + static Map map = new HashMap<>(); + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + + int[] seq = new int[N]; + + long sum = 0; + + for(int i=0;i map = new HashMap<>(); + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + int M = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + + int[] seq = new int[N]; + int[] sorted = new int[N]; + + boolean flag = false; + + for(int i=0;i =0;i--) { + + if(seq[i] == sorted[i]) { + continue; + } + + int index = map.get(sorted[i]); + + map.put(seq[i], index); + map.put(sorted[i], i); + + int temp = seq[i]; + seq[i] = seq[index]; + seq[index] = temp; + + if(++change == M) { + bw.write(temp + " " + seq[i] + "\n"); + flag = !flag; + break; + } + + } + + if(!flag) { + bw.write(-1+"\n"); + } + + bw.flush(); + } +} diff --git a/dydwo0740/baekjoon/2513.java b/dydwo0740/baekjoon/2513.java new file mode 100644 index 0000000..a80f7c6 --- /dev/null +++ b/dydwo0740/baekjoon/2513.java @@ -0,0 +1,84 @@ +import java.io.*; +import java.util.*; +import java.util.stream.*; + +public class Main { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int K = Integer.parseInt(st.nextToken()); + int S = Integer.parseInt(st.nextToken()); + + PriorityQueue left = new PriorityQueue<>((o1, o2) -> o1[0] - o2[0]); + PriorityQueue right = new PriorityQueue<>((o1, o2) -> o2[0] - o1[0]); + + for(int i=0;i > info = new HashMap<>(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + + M = Integer.parseInt(st.nextToken()); + + S = Integer.parseInt(st.nextToken()); + + char[] count = new char[27]; + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + String str = st.nextToken(); + for (int j = 0; j < M; j++) { + if (!info.containsKey(str.charAt(j))) { + List list = new ArrayList<>(); + list.add(new Location(i, j)); + info.put(str.charAt(j), list); + continue; + } + List list = info.get(str.charAt(j)); + list.add(new Location(i, j)); + } + } + + + st = new StringTokenizer(br.readLine()); + + id = st.nextToken(); + + for (int i = 0; i < id.length(); i++) { + count[id.charAt(i) - 'a']++; + } + + for (int i = 0; i < 27; i++) { + if (count[i] > 0) { + if(!info.containsKey((char) ('a' + i))){ + ans = 0; + continue; + } + ans = Math.min(ans, info.get((char) ('a' + i)).size() / count[i]); + } + } + + String move = ""; + Location start = new Location(0, 0); + + for (int i = 0; i < ans; i++) { + for (int j = 0; j < id.length(); j++) { + int[] s = new int[2]; + int[] e = new int[2]; + Location end = info.get(id.charAt(j)).get(0); + move += (bfs(new int[]{start.x, start.y}, new int[]{end.x, end.y}) + "P"); + start = new Location(end.x, end.y); + info.get(id.charAt(j)).remove(0); + } + } + + move += bfs(new int[]{start.x, start.y}, new int[]{N-1, M-1}); + bw.write(ans + " " + move.length() + "\n"); + bw.write(move + "\n"); + bw.flush(); + } + + + public static String bfs(int[] s, int[] e) { + Queue queue = new LinkedList<>(); + queue.add(new Location(s[0], s[1], "")); + boolean[][] visited = new boolean[N][M]; + visited[s[0]][s[1]] = true; + + while (!queue.isEmpty()) { + Location cur = queue.poll(); + + if (cur.x == e[0] && cur.y == e[1]) { + return cur.move; + } + + for (int i = 0; i < 4; i++) { + int nx = cur.x + row[i]; + int ny = cur.y + col[i]; + if (0 <= nx && nx < N && 0 <= ny && ny < M) { + if (!visited[nx][ny]) { + visited[nx][ny] = true; + queue.add(new Location(nx, ny, cur.move + String.valueOf(alpha[i]))); + } + } + } + } + + return null; + } +} diff --git a/dydwo0740/baekjoon/25391.java b/dydwo0740/baekjoon/25391.java new file mode 100644 index 0000000..a3cd0c2 --- /dev/null +++ b/dydwo0740/baekjoon/25391.java @@ -0,0 +1,66 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static class Point{ + int honor; + int referee; + + public Point(int honor, int referee) { + this.honor = honor; + this.referee = referee; + } + } + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + int M = Integer.parseInt(st.nextToken()); + + int K = Integer.parseInt(st.nextToken()); + + PriorityQueue pq = new PriorityQueue<>(new Comparator () { + @Override + public int compare(Point o1, Point o2) { + if (o2.referee == o1.referee) { + return o2.honor - o1.honor; + } + return o2.referee - o1.referee; + } + }); + + for(int i=0;i honor = new PriorityQueue<>(Comparator.reverseOrder()); + + while (!pq.isEmpty()) { + honor.add(pq.poll().honor); + } + + for(int i=0;i map = new HashMap<>(); + + st = new StringTokenizer(br.readLine()); + + for(int i=0;i list = new ArrayList<>(); + + for (Map.Entry entry : map.entrySet()) { + if(entry.getValue() > 1){ + list.add(entry.getKey()); + list.add(entry.getKey()); + } else{ + list.add(entry.getKey()); + } + } + + combination(new int[2], new boolean[N], list.stream() + .mapToInt(Integer::intValue) + .toArray(), 0, 0); + bw.write(ans+"\n"); + bw.flush(); + } + + public static void combination(int[] output, boolean[] visited, int[] seq, int depth, int start){ + if(output.length == depth){ + ans = Math.max(ans, getValue(output[0] * output[1])); + return; + } + + for(int i = start;i 0){ + ans += (num % 10); + num /= 10; + } + + return ans; + } + + +} diff --git a/dydwo0740/baekjoon/2655.java b/dydwo0740/baekjoon/2655.java new file mode 100644 index 0000000..fd12174 --- /dev/null +++ b/dydwo0740/baekjoon/2655.java @@ -0,0 +1,83 @@ +import java.io.*; +import java.util.*; + +public class Main { + static class Node { + int idx; + int size; + int h; + int w; + + public Node(int idx, int size, int h, int w) { + this.idx = idx; + this.size = size; + this.h = h; + this.w = w; + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + List seq = new ArrayList<>(); + + int N = Integer.parseInt(st.nextToken()); + int[] height = new int[N + 1]; + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + int size = Integer.parseInt(st.nextToken()); + int h = Integer.parseInt(st.nextToken()); + int w = Integer.parseInt(st.nextToken()); + + seq.add(new Node(i + 1, size, h, w)); + height[i + 1] = h; + } + + seq.sort(new Comparator () { + @Override + public int compare(Node o1, Node o2) { + return o1.size - o2.size; + } + }); + + + // LIS + + int[] dp = new int[N]; + int max = 0; + + for (int i = 0; i < N; i++) { + dp[i] = seq.get(i).h; + for (int j = 0; j < i; j++) { + if (seq.get(i).w > seq.get(j).w) { + dp[i] = Math.max(dp[i], dp[j] + seq.get(i).h); + } + } + + max = Math.max(max, dp[i]); + } + + + Stack stack = new Stack<>(); + + for (int i = N - 1; i >= 0; i--) { + if (dp[i] == max) { + stack.push(seq.get(i).idx); + max -= seq.get(i).h; + } + } + + bw.write(stack.size()+"\n"); + while (!stack.isEmpty()) { + bw.write(stack.pop() + "\n"); + } + + + bw.flush(); + } + + +} diff --git a/dydwo0740/baekjoon/2746.java b/dydwo0740/baekjoon/2746.java new file mode 100644 index 0000000..1efcf7b --- /dev/null +++ b/dydwo0740/baekjoon/2746.java @@ -0,0 +1,95 @@ +import java.io.*; +import java.util.*; +import java.util.stream.Collectors; + +public class Main { + static Map map; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + long[] seq = new long[N]; + + st = new StringTokenizer(br.readLine()); + + for (int i = 0; i < N; i++) { + seq[i] = Long.parseLong(st.nextToken()); + } + + Arrays.sort(seq); + + long cnt = 0; + + // 어차피 맨뒤 or 그 앞 or 그 앞앞 즉, N, N-1, N-2 가 가장 큰 것이 됩니다 + + // N 에 대해서 + long total = 0; + map = new HashMap<>(); + + for (int i = 0; i < N - 1; i++) { + total += seq[i]; + map.put(seq[i], map.getOrDefault(seq[i], 0L) + 1); + } + + total -= seq[N - 1]; + + for (int i = 0; i < N - 1; i++) { + long other = total - seq[i]; + + if (other <= 0) { + continue; + } + + if (other != seq[i]) { + if (map.containsKey(seq[i]) && map.containsKey(other)) { + cnt += map.get(other) * map.get(seq[i]); + map.remove(seq[i]); + map.remove(other); + } + } else { + if (map.containsKey(other) && map.get(other) > 1L) { + cnt += getComb(map.get(seq[i])); + map.remove(seq[i]); + } + } + } + + total = 0; + map.clear(); + + for (int i = 0; i < N - 2; i++) { + total += seq[i]; + map.put(seq[i], map.getOrDefault(seq[i], 0L) + 1); + } + + total -= seq[N - 2]; + cnt += map.getOrDefault(total, 0L); + + total = 0; + map.clear(); + + for (int i = 0; i < N - 3; i++) { + total += seq[i]; + } + + total -= seq[N - 3]; + + if(total == 0) { + cnt++; + } + + + bw.write(cnt + "\n"); + + bw.flush(); + } + + public static long getComb(long num) { + + return num * (num - 1) / 2; + } +} diff --git a/dydwo0740/baekjoon/27924.java b/dydwo0740/baekjoon/27924.java new file mode 100644 index 0000000..d0cd063 --- /dev/null +++ b/dydwo0740/baekjoon/27924.java @@ -0,0 +1,86 @@ +import java.io.*; +import java.util.*; + +public class Main { + static int N; + static List [] g; + static Set leafNodes; + static int[][] dist; + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + + g = new ArrayList[N + 1]; + leafNodes = new HashSet<>(); + dist = new int[3][N + 1]; + + for(int i=0;i<3;i++) { + Arrays.fill(dist[i], -1); + } + + for(int i=1;i<=N;i++) { + g[i] = new ArrayList<>(); + } + + for(int i=0;i iter = leafNodes.iterator(); + + boolean flag = true; + + while(iter.hasNext()) { + int next = iter.next(); + + if(dist[0][next] < dist[1][next] && dist[0][next] < dist[2][next]) { + flag = false; + break; + } + } + + if(flag) { + bw.write("NO"); + } else { + bw.write("YES"); + } + + bw.flush(); + } + + public static void initialize(int from, int to, int depth) { + dist[from][to] = depth; + for(int i = 0;i answer) { + answer = sum; + ans = move; + } + + int type = -1; + int max = -1; + + if (sX - 1 >= 1 && rowSum(sY, eY, sX - 1) >= 0) { + if (max < rowSum(sY, eY, sX - 1)) { + type = 0; + max = rowSum(sY, eY, sX - 1); + } + } + + if (eX + 1 <= N && rowSum(sY, eY, eX + 1) >= 0) { + if (max < rowSum(sY, eY, eX + 1)) { + type = 1; + max = rowSum(sY, eY, eX + 1); + } + } + + if (sY - 1 >= 1 && colSum(sX, eX, sY - 1) >= 0) { + if (max < colSum(sX, eX, sY - 1)) { + type = 2; + max = colSum(sX, eX, sY - 1); + } + } + + if (eY + 1 <= N && colSum(sX, eX, eY + 1) >= 0) { + if (max < colSum(sX, eX, eY + 1)) { + type = 3; + max = colSum(sX, eX, eY + 1); + } + } + + + if (type == -1) { + return; + } + + if (type == 0) { + dfs(sX - 1, sY, eX, eY, sum + rowSum(sY, eY, sX - 1), move + "U"); + } else if (type == 1) { + dfs(sX, sY, eX + 1, eY, sum + rowSum(sY, eY, eX + 1), move + "D"); + } else if (type == 2) { + dfs(sX, sY - 1, eX, eY, sum + colSum(sX, eX, sY - 1), move + "L"); + } else { + dfs(sX, sY, eX, eY + 1, sum + colSum(sX, eX, eY + 1), move + "R"); + } + + + } + + public static int rowSum(int start, int end, int row) { + int sum = 0; + while (start <= end) { + sum += board[row][start++]; + } + + return sum; + } + + public static int colSum(int start, int end, int col) { + int sum = 0; + while (start <= end) { + sum += board[start++][col]; + } + + return sum; + } + + +} diff --git a/dydwo0740/baekjoon/28017.java b/dydwo0740/baekjoon/28017.java new file mode 100644 index 0000000..8b2c6ae --- /dev/null +++ b/dydwo0740/baekjoon/28017.java @@ -0,0 +1,40 @@ +import java.io.*; +import java.util.*; + +public class Main { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + int[][] dp = new int[N + 1][M]; + + + for (int i = 1; i <= N; i++) { + st = new StringTokenizer(br.readLine()); + for (int j = 0; j < M; j++) { + int min = Integer.MAX_VALUE; + for (int k = 0; k < M; k++) { + if (j == k) { + continue; + } + min = Math.min(min, dp[i - 1][k]); + } + int num = Integer.parseInt(st.nextToken()); + dp[i][j] = min + num; + } + + } + int ans = Integer.MAX_VALUE; + for (int i = 0; i < M; i++) { + ans = Math.min(dp[N][i], ans); + } + bw.write(ans + "\n"); + bw.flush(); + } + + +} diff --git a/dydwo0740/baekjoon/28270.java b/dydwo0740/baekjoon/28270.java new file mode 100644 index 0000000..8d6bcf9 --- /dev/null +++ b/dydwo0740/baekjoon/28270.java @@ -0,0 +1,67 @@ + +import java.io.*; +import java.util.*; + +public class Main { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + // 형제 노드란 부모가 같습니다. 선형적으로 선정 + // 형제 노드! + + int N = Integer.parseInt(st.nextToken()); + + int[] seq = new int[N]; + int[] count = new int[1000001]; + int[] answer = new int[N]; + + Arrays.fill(count, 1); + + int max = 1; + + st = new StringTokenizer(br.readLine()); + + for(int i=0;i = N ? (i + start) % N : i + start; + if (!visited[idx]) { + visited[idx] = true; + int left = idx - 1; + int right = idx + 1; + if (idx == 0) { + left = N - 1; + } else if (idx == N - 1) { + right = 0; + } + + if (empty[left] == -1 && empty[right] == -1) { + empty[idx] = 1; + ans++; + } else if (empty[left] == 1 || empty[right] == 1) { + + } else { + empty[idx] = 1; + ans++; + } + + //bw.write(i + " " + ans+" " + empty[left] + " " + empty[right] + "\n"); + } + } + + bw.write(ans + "\n"); + + bw.flush(); + } + + +} diff --git a/dydwo0740/baekjoon/28359.java b/dydwo0740/baekjoon/28359.java new file mode 100644 index 0000000..4eb7d6d --- /dev/null +++ b/dydwo0740/baekjoon/28359.java @@ -0,0 +1,77 @@ +import java.io.*; +import java.util.*; +import java.util.stream.*; + +public class Main { + static Map map = new HashMap<>(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + List list = new ArrayList<>(); + List answer = new ArrayList<>(); + st = new StringTokenizer(br.readLine()); + + for (int i = 0; i < N; i++) { + int num = Integer.parseInt(st.nextToken()); + + if (map.containsKey(num)) { + map.put(num, map.get(num) + 1); + continue; + } + + map.put(num, 1); + list.add(num); + } + + list.sort(Comparator.naturalOrder()); + answer.addAll(list); + + int max = 0; + for (int i = 0; i < list.size(); i++) { + max += (list.get(i) * map.get(list.get(i))); + } + + int desc = 0; + for(int i=0;i origin = new HashSet<>(); + + for (int i = 0; i < N; i++) { + seq[i] = Integer.parseInt(st.nextToken()); + origin.add(seq[i]); + } + + int[] diff = new int[N - 1]; + + for (int i = 1; i < N; i++) { + diff[i - 1] = seq[i] - seq[0]; + } + + List list = new ArrayList<>(); + + for (int i = 0; i < N - 1; i++) { + int differ = diff[i]; + Set set = new HashSet<>(origin); + boolean flag = true; + + for (int j = 0; j < N - 1; j++) { + if(!set.contains(seq[j])){ + if (set.contains(seq[j] + differ)) { + set.remove(seq[j] + differ); + } + continue; + } + + if (!set.contains(seq[j] + differ)) { + flag = false; + break; + } + + set.remove(seq[j]); + set.remove(seq[j] + differ); + } + + if (flag && set.isEmpty()) { + list.add(differ); + } + } + + if (list.size() == 0) { + bw.write(0+"\n"); + bw.flush(); + return; + } + + bw.write(list.size() + "\n"); + + for (int i = 0; i < list.size(); i++) { + bw.write(list.get(i) + " "); + } + + bw.flush(); + } + + +} diff --git a/dydwo0740/baekjoon/30108.java b/dydwo0740/baekjoon/30108.java new file mode 100644 index 0000000..2519f3b --- /dev/null +++ b/dydwo0740/baekjoon/30108.java @@ -0,0 +1,37 @@ +import java.awt.*; +import java.io.*; +import java.util.*; + +public class Main { + + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + + st = new StringTokenizer(br.readLine()); + + Integer[] seq = new Integer[N]; + + for(int i=0;i seqA = new PriorityQueue<>((o1, o2) -> { + if (o1.value == o2.value) { + return o1.index - o2.index; + } + + return o2.value - o1.value; + }); + + PriorityQueue seqB = new PriorityQueue<>((o1, o2) -> { + if (o1.value == o2.value) { + return o1.index - o2.index; + } + + return o2.value - o1.value; + }); + + int N = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + + for (int i = 0; i < N; i++) { + int value = Integer.parseInt(st.nextToken()); + seqA.add(new Node(value, i)); + } + + st = new StringTokenizer(br.readLine()); + + int M = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + + for (int i = 0; i < M; i++) { + int value = Integer.parseInt(st.nextToken()); + seqB.add(new Node(value, i)); + } + + int prevA = -1; + int prevB = -1; + + List list = new ArrayList<>(); + + while (!seqB.isEmpty() && !seqA.isEmpty()) { + + boolean flag = false; + + if(seqA.peek().index < prevA) { + flag = true; + seqA.poll(); + } + + if(seqB.peek().index < prevB) { + flag = true; + seqB.poll(); + } + + if(flag) { + continue; + } + + if (seqA.peek().value == seqB.peek().value) { + prevA = seqA.peek().index; + prevB = seqB.peek().index; + list.add(seqA.peek().value); + seqA.poll(); + seqB.poll(); + } else if (seqA.peek().value > seqB.peek().value) { + seqA.poll(); + } else { + seqB.poll(); + } + } + + bw.write(list.size() + "\n"); + + for(int i=0;i > row = new HashMap<>(); + static Map > col = new HashMap<>(); + static int N; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + + int M = Integer.parseInt(st.nextToken()); + + // 초기화 + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + + int x = Integer.parseInt(st.nextToken()); + int y = Integer.parseInt(st.nextToken()); + + if (!row.containsKey(x)) { + ArrayList list = new ArrayList<>(); + list.add(y); + row.put(x, list); + } else { + List list = row.get(x); + list.add(y); + } + + if (!col.containsKey(y)) { + ArrayList list = new ArrayList<>(); + list.add(x); + col.put(y, list); + } else { + List list = col.get(y); + list.add(x); + } + } + + st = new StringTokenizer(br.readLine()); + + String str = st.nextToken(); + + int x = 0; + int y = 0; + + for (Map.Entry > entry : row.entrySet()) { + List list = entry.getValue(); + list.sort(Comparator.naturalOrder()); + } + + for (Map.Entry > entry : col.entrySet()) { + List list = entry.getValue(); + list.sort(Comparator.naturalOrder()); + } + + for (int i = 0; i < M; i++) { + char ch = str.charAt(i); + + if (ch == 'U') { + List list = row.get(x); + int value = binarySearch(y, list); + y = list.get(value + 1); + } else if (ch == 'D') { + List list = row.get(x); + int value = binarySearch(y, list); + y = list.get(value - 1); + } else if (ch == 'R') { + List list = col.get(y); + int value = binarySearch(x, list); + x = list.get(value + 1); + } else { + List list = col.get(y); + int value = binarySearch(x, list); + x = list.get(value - 1); + } + + //System.out.println("x + \" \" + y = " + x + " " + y); + } + + bw.write(x + " " + y + "\n"); + + + bw.flush(); + } + + public static int binarySearch(int target, List list) { + int start = 0; + int end = list.size() - 1; + + while (start <= end) { + int mid = (start + end) / 2; + + if (list.get(mid) < target) { + start = mid + 1; + } else if (list.get(mid) == target) { + return mid; + } else { + end = mid - 1; + } + } + + return 0; + } +} diff --git a/dydwo0740/baekjoon/3107.java b/dydwo0740/baekjoon/3107.java new file mode 100644 index 0000000..bae1d39 --- /dev/null +++ b/dydwo0740/baekjoon/3107.java @@ -0,0 +1,78 @@ +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.StringTokenizer; + + +public class Main { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + String str = st.nextToken(); + + String[] s = str.split(":"); + + if(s.length == 0) { + String ans = ""; + for(int i=0;i<7;i++) { + ans += "0".repeat(4) + ":"; + } + ans += "0".repeat(4); + bw.write(ans+"\n"); + bw.flush(); + return; + } + + if(s.length == 8) { + for(int i=0;i L 은 왼쪽부터, D는 오른쪽부터 + + List answer = new ArrayList<>(); + + int L = Integer.parseInt(st.nextToken()); + + int T = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + + int cur = Integer.parseInt(st.nextToken()); + String s = st.nextToken(); + char head = s.charAt(0); + + + if (head == 'L') { + int total = T + L - cur; + if (total < L) { + answer.add(L - total); + } else { + if ((total / L) % 2 == 0) { + answer.add(L - total % L); + } else { + answer.add(total % L); + } + } + } else { + int total = T + cur; + if (total < L) { + answer.add(total); + } else { + if ((total / L) % 2 == 0) { + answer.add(total % L); + } else { + answer.add(L - total % L); + } + } + } + } + + + answer.sort(Comparator.naturalOrder()); + + for(int i=0;i one2) { + bw.write("Case " + test + ": " + -1 + "\n"); + continue; + } + + int add = 0; + + // before 에 1이 더 많다.. + + Map map = new HashMap<>(); + + for(int i=0;i zero2) { + zero1--; + add++; + map.put(i, '1'); + } + } + + int restOne = one2 - one1; + int restZero = zero2 - zero1; + + String comp = ""; + + + + for (int i = 0; i < before.length(); i++) { + if (before.charAt(i) == '?') { + if (after.charAt(i) == '0' && restZero > 0) { + restZero--; + comp += String.valueOf('0'); + } else if (after.charAt(i) == '1' && restOne > 0) { + restOne--; + comp += String.valueOf('1'); + } else { + if (restZero > 0) { + comp += String.valueOf('0'); + } else { + comp += String.valueOf('1'); + } + } + add++; + } else { + if(map.containsKey(i)) { + comp += String.valueOf(map.get(i)); + continue; + } + comp += String.valueOf(before.charAt(i)); + } + } + + + int change = 0; + for (int i = 0; i < comp.length(); i++) { + if (comp.charAt(i) != after.charAt(i)) { + change++; + } + } + + bw.write("Case " + test + ": " + (add+ (change / 2)) + "\n"); + + } + + bw.flush(); + + } + +} diff --git a/dydwo0740/baekjoon/4650.java b/dydwo0740/baekjoon/4650.java new file mode 100644 index 0000000..4840e65 --- /dev/null +++ b/dydwo0740/baekjoon/4650.java @@ -0,0 +1,111 @@ +import org.w3c.dom.Node; + +import java.io.*; +import java.util.*; + +public class Main { + static int N; + static int[] parent; + static class Node{ + int v1; + int v2; + int dist; + + public Node(int v1, int v2, int dist) { + this.v1 = v1; + this.v2 = v2; + this.dist = dist; + } + } + + static int ans = Integer.MAX_VALUE; + + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st; + while(true) { + st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + + if (N == 0) { + break; + } + + + PriorityQueue pq = new PriorityQueue<>(new Comparator () { + @Override + public int compare(Node o1, Node o2) { + return o1.dist - o2.dist; + } + }); + + parent = new int[N + 1]; + + for (int i = 1; i <= N; i++) { + parent[i] = i; + } + + for (int i = 0; i < N - 1; i++) { + st = new StringTokenizer(br.readLine()); + + String str = st.nextToken(); + + int cur = str.charAt(0) - 'A' + 1; + + int M = Integer.parseInt(st.nextToken()); + + for (int j = 0; j < M; j++) { + str = st.nextToken(); + + int next = str.charAt(0) - 'A' + 1; + int dist = Integer.parseInt(st.nextToken()); + + pq.add(new Node(cur, next, dist)); + + } + } + int sum = 0; + while (!pq.isEmpty()) { + Node node = pq.poll(); + sum += union(node.v1, node.v2, node.dist); + } + + bw.write(sum+"\n"); + + } + + + bw.flush(); + } + + public static int getParent(int x) { + if (parent[x] == x) { + return x; + } + + return parent[x] = getParent(parent[x]); + } + + public static int union(int x, int y, int dist) { + x = getParent(x); + y = getParent(y); + + if(x == y){ + return 0; + } + + if(x < y){ + parent[y] = x; + } else { + parent[x] = y; + } + + return dist; + } + + + +} diff --git a/dydwo0740/baekjoon/4920.java b/dydwo0740/baekjoon/4920.java new file mode 100644 index 0000000..c7a1d2a --- /dev/null +++ b/dydwo0740/baekjoon/4920.java @@ -0,0 +1,95 @@ +import org.w3c.dom.Node; + +import java.io.*; +import java.util.*; + +public class Main { + + + static int[][] row = {{0, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 1}, {0, 1, 0}}; + static int[][] col = {{1, 1, 1}, {1, 0, 1}, {1, 1, 0}, {1, 1, -1}, {1, 0, -1}}; + + static int[][] board; + static int N; + static int max; + static int test = 1; + + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st; + + while (true) { + st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + + if (N == 0) { + break; + } + + board = new int[N][N]; + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + for (int j = 0; j < N; j++) { + board[i][j] = Integer.parseInt(st.nextToken()); + } + } + + max = Integer.MIN_VALUE; + + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + solve(i, j); + } + } + bw.write(test++ + ". " + max + "\n"); + } + + bw.flush(); + } + + public static void solve(int x, int y) { + for (int i = 0; i < row.length; i++) { + int type = 0; + while (type++ < 4) { + int sum = board[x][y]; + boolean flag = false; + rotate(i); + int nx = x; + int ny = y; + for (int j = 0; j < row[i].length; j++) { + nx += row[i][j]; + ny += col[i][j]; + if (0 <= nx && nx < N && 0 <= ny && ny < N) { + sum += board[nx][ny]; + } else { + flag = true; + break; + } + } + + if (flag) { + continue; + } + if (max < sum) { + max = sum; + } + } + + + } + } + + public static void rotate(int index) { + for (int i = 0; i < row[index].length; i++) { + int tempRow = row[index][i]; + int tempCol = col[index][i]; + + row[index][i] = tempCol; + col[index][i] = -tempRow; + } + } +} diff --git a/dydwo0740/baekjoon/5502.java b/dydwo0740/baekjoon/5502.java new file mode 100644 index 0000000..12d53ca --- /dev/null +++ b/dydwo0740/baekjoon/5502.java @@ -0,0 +1,51 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static class Node{ + String str; + int cnt; + + public Node(String str, int cnt) { + this.str = str; + this.cnt = cnt; + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + + StringBuilder sb = new StringBuilder(); + + sb.append(st.nextToken()); + + StringBuilder reverse = new StringBuilder(sb).reverse(); + + int[][] dp = new int[N + 1][N + 1]; + + for (int i = 1; i <= N; i++) { + for (int j = 1; j <= N; j++) { + if (sb.charAt(i - 1) == reverse.charAt(j - 1)) { + dp[i][j] = dp[i-1][j-1] + 1; + } else{ + dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]); + } + } + } + + + bw.write(N - dp[N][N]+"\n"); + + bw.flush(); + } + + + +} diff --git a/dydwo0740/baekjoon/5547.java b/dydwo0740/baekjoon/5547.java new file mode 100644 index 0000000..f23d60d --- /dev/null +++ b/dydwo0740/baekjoon/5547.java @@ -0,0 +1,159 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static int[] rowOdd = {0, 1, 1, 1, 0, -1}; + static int[] colOdd = {-1, -1, 0, 1, 1, 0}; + static int[] rowEven = {-1, 0, 1, 0, -1, -1}; + static int[] colEven = {-1, -1, 0, 1, 1, 0}; + static int N; + static int M; + static List list; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + M = Integer.parseInt(st.nextToken()); + + N = Integer.parseInt(st.nextToken()); + + int[][] board = new int[N + 1][M + 1]; + + for (int i = 1; i <= N; i++) { + st = new StringTokenizer(br.readLine()); + + for (int j = 1; j <= M; j++) { + board[i][j] = Integer.parseInt(st.nextToken()); + } + } + + int ans = 0; + int minus = 0; + + boolean[][] visited = new boolean[N + 1][M + 1]; + + for(int i=1;i<=N;i++){ + for(int j=1;j<=M;j++){ + if(board[i][j] == 1){ + ans += getCoverEdge(board, i, j); + } else{ + list = new ArrayList<>(); + //System.out.println("i + \" \" + j = " + i + " " + j); + if (bfs(i, j, board) && !visited[i][j]) { + //bw.write(i + " " + j + " 입니다.\n"); + for (int k = 0; k < list.size(); k++) { + int[] index = list.get(k); + visited[index[0]][index[1]] = true; + minus += (6 - getCoverEdge(board, index[0], index[1])); + } + } + } + } + } + + + bw.write((ans - minus) + "\n"); + + bw.flush(); + + } + + public static int[] changeIndex(int x, int y) { + return new int[]{y, x}; + } + + public static int getCoverEdge(int[][] board, int x, int y) { + int[] index = changeIndex(x, y); + + x = index[0]; + y = index[1]; + + int cnt = 0; + + if(y % 2==0){ + for (int i = 0; i < 6; i++) { + int nx = x + rowEven[i]; + int ny = y + colEven[i]; + + index = changeIndex(nx, ny); + + if (1 <= index[0] && index[0] <= N && 1 <= index[1] && index[1] <= M) { + if (board[index[0]][index[1]] == 0) { + cnt++; + } + } else{ + cnt++; + } + } + + return cnt; + } + + for (int i = 0; i < 6; i++) { + int nx = x + rowOdd[i]; + int ny = y + colOdd[i]; + + index = changeIndex(nx, ny); + + if (1 <= index[0] && index[0] <= N && 1 <= index[1] && index[1] <= M) { + if (board[index[0]][index[1]] == 0) { + cnt++; + } + } else{ + cnt++; + } + } + + return cnt; + } + + public static boolean bfs(int x, int y, int[][] board) { + Queue queue = new LinkedList<>(); + boolean[][] visited = new boolean[N + 1][M + 1]; + + list.add(new int[]{x, y}); + visited[x][y] = true; + queue.add(new int[]{x, y}); + + while (!queue.isEmpty()) { + int[] cur = queue.poll(); + + if (cur[0] == 1 || cur[0] == N || cur[1] == 1 || cur[1] == M) { + return false; + } + + int[] index = changeIndex(cur[0], cur[1]); + + for(int i=0;i<6;i++){ + if(index[1] % 2 == 0){ + int nx = index[0] + rowEven[i]; + int ny = index[1] + colEven[i]; + + int[] next = changeIndex(nx, ny); + + if (!visited[next[0]][next[1]] && board[next[0]][next[1]] == 0) { + list.add(new int[]{next[0], next[1]}); + queue.add(new int[]{next[0], next[1]}); + visited[next[0]][next[1]] = true; + } + } else{ + int nx = index[0] + rowOdd[i]; + int ny = index[1] + colOdd[i]; + + int[] next = changeIndex(nx, ny); + + if (!visited[next[0]][next[1]] && board[next[0]][next[1]] == 0) { + list.add(new int[]{next[0], next[1]}); + queue.add(new int[]{next[0], next[1]}); + visited[next[0]][next[1]] = true; + } + } + } + } + + return true; + } +} diff --git a/dydwo0740/baekjoon/5931.java b/dydwo0740/baekjoon/5931.java new file mode 100644 index 0000000..8fd6d33 --- /dev/null +++ b/dydwo0740/baekjoon/5931.java @@ -0,0 +1,86 @@ +import java.io.*; +import java.util.*; + +public class Main { + static int[] row = {1, -1, 0, 0}; + static int[] col = {0, 0, 1, -1}; + static int N; + static int M; + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + + List partA = new ArrayList<>(); + List partB = new ArrayList<>(); + + char[][] board = new char[N][M]; + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + + String str = st.nextToken(); + for (int j = 0; j < M; j++) { + board[i][j] = str.charAt(j); + } + } + + boolean[][] visited = new boolean[N][M]; + boolean flag = true; + + for(int i=0;i part) { + Queue queue = new LinkedList<>(); + visited[x][y] = true; + queue.add(new int[]{x, y}); + + part.add(new int[]{x, y}); + + while (!queue.isEmpty()) { + int[] cur = queue.poll(); + + for (int i = 0; i < 4; i++) { + int nx = cur[0] + row[i]; + int ny = cur[1] + col[i]; + + if (0 <= nx && nx < N && 0 <= ny && ny < M) { + if (!visited[nx][ny] && board[nx][ny] == 'X') { + part.add(new int[]{nx, ny}); + queue.add(new int[]{nx, ny}); + visited[nx][ny] = true; + } + } + } + } + } +} diff --git a/dydwo0740/baekjoon/7983.java b/dydwo0740/baekjoon/7983.java new file mode 100644 index 0000000..6fabc40 --- /dev/null +++ b/dydwo0740/baekjoon/7983.java @@ -0,0 +1,48 @@ +import java.io.*; +import java.util.*; + +public class Main { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + PriorityQueue pq = new PriorityQueue<>(new Comparator () { + @Override + public int compare(int[] o1, int[] o2) { + return o2[1] - o1[1]; + } + }); + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + + int d = Integer.parseInt(st.nextToken()); + int t = Integer.parseInt(st.nextToken()); + + pq.add(new int[]{d, t}); + } + + int[] cur = pq.poll(); + + int std = cur[1] - cur[0]; + + while (!pq.isEmpty()) { + cur = pq.poll(); + + if (std < cur[1]) { + std -= cur[0]; + } else{ + std = cur[1] - cur[0]; + } + } + + bw.write(std+"\n"); + + bw.flush(); + } + +} diff --git a/dydwo0740/baekjoon/9011.java b/dydwo0740/baekjoon/9011.java new file mode 100644 index 0000000..2d32730 --- /dev/null +++ b/dydwo0740/baekjoon/9011.java @@ -0,0 +1,64 @@ +package swexperttest; + +import java.io.*; +import java.util.*; + +public class Main { + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int T = Integer.parseInt(st.nextToken()); + + for(int test = 1;test<=T;test++) { + st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + + int[] seq = new int[N]; + + for(int i=0;i list = new ArrayList<>(); + + for(int i=N;i>=1;i--) { + list.add(i); + } + + int index = N - 1; + int[] answer = new int[N]; + boolean flag = false; + for(int i=N-1;i>=0;i--) { + int diff = index - seq[i]; + + if(diff < 0) { + flag = true; + break; + } + + index--; + answer[i] = list.remove(diff); + } + + if(flag) { + bw.write("IMPOSSIBLE\n"); + } else { + for(int i=0;i [] g; + static int[] prev; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int T = Integer.parseInt(st.nextToken()); + + for (int test = 1; test <= T; test++) { + st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + + M = Integer.parseInt(st.nextToken()); + + g = new ArrayList[M]; + + + for(int i=0;i (); + } + + prev = new int[M]; + Arrays.fill(prev, -1); + + for(int i=0;i stack = new Stack<>(); + stack.push(M - 1); + for (int i = (M-1); i > 0;) { + stack.push(i = prev[i]); + } + + if (dist[M-1] == Integer.MAX_VALUE) { + bw.write("Case #" + test + ": " + -1 + "\n"); + continue; + } + + bw.write("Case #" + test + ":"); + while(!stack.empty()) { + bw.write(" " + stack.pop()); + } + bw.write("\n"); + + + + } + + + bw.flush(); + } + + public static int[] dijkstra() { + int[] dist = new int[M]; + Arrays.fill(dist, Integer.MAX_VALUE); + PriorityQueue pq = new PriorityQueue<>(new Comparator () { + @Override + public int compare(Node o1, Node o2) { + return o1.cost - o2.cost; + } + }); + pq.add(new Node(0, 0)); + dist[0] = 0; + + while (!pq.isEmpty()) { + Node cur = pq.poll(); + + if (cur.cost > dist[cur.v]) { + continue; + } + + for (int i = 0; i < g[cur.v].size(); i++) { + int next = g[cur.v].get(i).v; + int cost = g[cur.v].get(i).cost; + if (dist[next] > cur.cost + cost) { + dist[next] = cur.cost + cost; + prev[next] = cur.v; + pq.add(new Node(next, dist[next])); + } + } + } + + return dist; + } + +} diff --git a/dydwo0740/baekjoon/9944.java b/dydwo0740/baekjoon/9944.java new file mode 100644 index 0000000..88ed0ab --- /dev/null +++ b/dydwo0740/baekjoon/9944.java @@ -0,0 +1,114 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static int N; + static int M; + static char[][] board; + static int dot = 0; + static int min = Integer.MAX_VALUE; + static int[] row = {1, -1, 0, 0}; + static int[] col = {0, 0, 1, -1}; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st; + + String input = ""; + int test = 1; + while ((input = br.readLine()) != null) { + + st = new StringTokenizer(input); + + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + + board = new char[N][M]; + min = Integer.MAX_VALUE; + dot = 0; + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + String str = st.nextToken(); + for (int j = 0; j < M; j++) { + board[i][j] = str.charAt(j); + if (board[i][j] == '.') { + dot++; + } + } + } + + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + if (board[i][j] == '.') { + boolean[][] visited = new boolean[N][M]; + visited[i][j] = true; + dfs(i, j, 1, 0, visited); + visited[i][j] = false; + } + } + } + + if (min == Integer.MAX_VALUE) { + System.out.println("Case " + test + ": " + -1); + } else{ + System.out.println("Case " + test + ": " + min); + } + + test++; + } + + + bw.flush(); + } + + public static void dfs(int x, int y, int cnt, int depth, boolean[][] visited) { + if (cnt == dot) { + min = Math.min(min, depth); + return; + } + + for (int i = 0; i < 4; i++) { + int nx = x + row[i]; + int ny = y + col[i]; + int count = 0; + // 계속해서 움직이게 하는 + while (isTrue(nx, ny) && !visited[nx][ny] && board[nx][ny] == '.') { + visited[nx][ny] = true; + count++; + nx += row[i]; + ny += col[i]; + + } + + nx -= row[i]; + ny -= col[i]; + + if (nx == x && ny == y) { + continue; + } + //System.out.println(nx + " " + ny + " " + cnt + " " + count); + + dfs(nx, ny, cnt + count, depth + 1, visited); + + for (int d = 1; d <= count; d++) { + nx = x + row[i] * d; + ny = y + col[i] * d; + visited[nx][ny] = false; + } + + } + + } + + public static boolean isTrue(int x, int y) { + if (0 <= x && x < N && 0 <= y && y < M) { + return true; + } + + return false; + } + +} diff --git a/kjhonggg95/baekjoon/10429.cpp b/kjhonggg95/baekjoon/10429.cpp new file mode 100644 index 0000000..055bc17 --- /dev/null +++ b/kjhonggg95/baekjoon/10429.cpp @@ -0,0 +1,90 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int dx[4] = {1, 0, -1, 0}; +int dy[4] = {0, 1, 0, -1}; + +int n, m; + +bool vis[3][3]; +char arr[3][3]; + +void dfs(int r, int c, int res, int cnt, char prev, vector v) +{ + v.push_back({r, c}); + + // 현재 칸이 숫자인 경우 + if (arr[r][c] >= '1' && arr[r][c] <= '9') + { + if (prev == '+') + res += (arr[r][c] - '0'); + else if (prev == '-') + res -= (arr[r][c] - '0'); + + cnt++; + + if (cnt == m) + { + if (res == n) + { + cout << 1 << '\n'; + for (auto e : v) + cout << e.X << ' ' << e.Y << '\n'; + exit(0); + } + + return; + } + } + else // 현재 칸이 연산자인 경우 + prev = arr[r][c]; + + for (int dir = 0; dir < 4; dir++) + { + int nx = r + dx[dir]; + int ny = c + dy[dir]; + + if (nx < 0 || nx >= 3 || ny < 0 || ny >= 3) + continue; + if (vis[nx][ny]) + continue; + + vis[nx][ny] = true; + dfs(nx, ny, res, cnt, prev, v); + vis[nx][ny] = false; + } +} + +int main() +{ + fastio; + cin >> n >> m; + for (int i = 0; i < 3; i++) + { + string s; + cin >> s; + for (int j = 0; j < 3; j++) + arr[i][j] = s[j]; + } + + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + if (arr[i][j] >= '0' && arr[i][j] <= '9') + { + vector v; + vis[i][j] = true; + dfs(i, j, arr[i][j] - '0', 0, 'x', v); + vis[i][j] = false; + } + } + } + + cout << 0 << '\n'; +} diff --git a/kjhonggg95/baekjoon/10710.cpp b/kjhonggg95/baekjoon/10710.cpp new file mode 100644 index 0000000..9006903 --- /dev/null +++ b/kjhonggg95/baekjoon/10710.cpp @@ -0,0 +1,36 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int d[1005]; // 거리 +int w[1005]; // 날씨 나쁨정도 +int dp[1005][1005]; // [i][j] : i번째 날 j번째 도시를 갈 때 최소 피로도 + +// 10 25 15 +// 50 30 15 40 30 + +int main() +{ + fastio; + memset(dp, 0x7f, sizeof(dp)); + int n, m; + cin >> n >> m; + for (int i = 1; i <= n; i++) + cin >> d[i]; + for (int i = 1; i <= m; i++) + cin >> w[i]; + + // 출발지(0번 도시)에서의 피로도는 0 + for (int i = 0; i <= m; i++) + dp[i][0] = 0; + + for (int i = 1; i <= m; i++) // 날씨 나쁨정도 + for (int j = 1; j <= n; j++) // 도시 + dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] + d[j] * w[i]); + + cout << dp[m][n] << '\n'; +} diff --git a/kjhonggg95/baekjoon/11607.cpp b/kjhonggg95/baekjoon/11607.cpp new file mode 100644 index 0000000..47862fb --- /dev/null +++ b/kjhonggg95/baekjoon/11607.cpp @@ -0,0 +1,55 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int dx[4] = {1,0,-1,0}; +int dy[4] = {0,1,0,-1}; + +char arr[501][501]; +bool vis[501][501]; + +int main() +{ + fastio; + int n, m; + cin >> n >> m; + for(int i = 0;i > arr[i][j]; + + queue > q; + + q.push({{0,0}, 0}); + vis[0][0] = true; + + while(!q.empty()) + { + auto cur = q.front().X; + auto cnt = q.front().Y; + q.pop(); + + if(cur.X == n - 1 && cur.Y == m - 1) + { + cout << cnt << '\n'; + return 0; + } + + for(int dir = 0;dir<4;dir++) + { + int nx = cur.X + dx[dir] * (arr[cur.X][cur.Y] - '0'); + int ny = cur.Y + dy[dir] * (arr[cur.X][cur.Y] - '0'); + + if(nx < 0 || nx >= n || ny < 0 || ny >=m) continue; + if(vis[nx][ny]) continue; + + q.push({{nx,ny}, cnt + 1}); + vis[nx][ny] = true; + } + } + + cout << "IMPOSSIBLE" << '\n'; +} \ No newline at end of file diff --git a/kjhonggg95/baekjoon/12764.cpp b/kjhonggg95/baekjoon/12764.cpp new file mode 100644 index 0000000..db9429f --- /dev/null +++ b/kjhonggg95/baekjoon/12764.cpp @@ -0,0 +1,93 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int n, p, q, ans; +int freq[100001]; // 자리별 앉은 횟수 +bool seat[100001]; // 착석 가능 여부 +map seatNo; // 시작/종료 시간 별 몇번자리에 앉아있는지 + +struct comp +{ + bool operator()(pii p1, pii p2) + { + if (p1.Y == p2.Y) + return p1.X > p2.X; + return p1.Y > p2.Y; + } +}; + +// 시작 시각이나 종료 시각이 다른 사람과 겹치는 경우는 없다 +// --> 시작/종료 시간 별 몇 번 자리에 앉았는지 독립적으로 저장 가능 + +int main() +{ + fastio; + cin >> n; + priority_queue , greater > in; + priority_queue , comp> out; + priority_queue , greater > mnseat; + for (int i = 1; i <= n; i++) + mnseat.push(i); + + for (int i = 0; i < n; i++) + { + cin >> p >> q; + in.push({p, q}); + } + + // 입장시간 순 + // 10 100 + // 20 50 + // 30 120 + // 60 110 + // 80 90 + + // 퇴장시간 순 + // 20 50 + // 80 90 + // 10 100 + // 60 110 + // 30 120 + + for (int t = 0; t <= 1000000; t++) + { + while (!in.empty() && t == in.top().X) // 입장 시간 + { + auto cur = in.top(); + out.push(cur); + in.pop(); + + // 착석 + // int k = findSeat(); // 앉을 수 있는 자리 중 번호가 가장 작은 자리 + int k = mnseat.top(); + mnseat.pop(); + seat[k] = true; + freq[k]++; + seatNo[cur] = k; + } + + while (!out.empty() && t == out.top().Y) // 퇴장 시간 + { + auto cur = out.top(); + out.pop(); + + // 종료 + int k = seatNo[cur]; + seat[k] = false; + mnseat.push(k); + } + + ans = max(ans, (int)out.size()); + } + + cout << ans << '\n'; + + for (int i = 1; i <= ans; i++) + cout << freq[i] << ' '; + cout << '\n'; +} diff --git a/kjhonggg95/baekjoon/12834.cpp b/kjhonggg95/baekjoon/12834.cpp new file mode 100644 index 0000000..2b883d4 --- /dev/null +++ b/kjhonggg95/baekjoon/12834.cpp @@ -0,0 +1,63 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int n, v, e, kist, cr, a, b, l; +ll ans; + +vector adj[1005]; +int d[1005]; + +// 다익스트라 O(ElogE) +// 각 집 -> kist, cr +// 집 최대 100 +// O(N * ElogE) + +int main() +{ + fastio; + cin >> n >> v >> e >> kist >> cr; + vector home(n); + for(int i = 0;i < n;i++) + cin >> home[i]; + + while(e--) + { + cin >> a >> b >> l; + adj[a].push_back({l, b}); + adj[b].push_back({l, a}); + } + + for(auto st : home) + { + memset(d, 0, sizeof(d)); + fill(d, d + v + 1, 1e9); + priority_queue , greater > pq; + d[st] = 0; + pq.push({d[st], st}); + + while(!pq.empty()) + { + auto cur = pq.top(); + pq.pop(); + + if(d[cur.Y] != cur.X) continue; + + for(auto nxt : adj[cur.Y]) + { + if(d[nxt.Y] <= d[cur.Y] + nxt.X) continue; + d[nxt.Y] = d[cur.Y] + nxt.X; + pq.push({d[nxt.Y], nxt.Y}); + } + } + + ans += (d[kist] == 1e9 ? -1 : d[kist]); + ans += (d[cr] == 1e9 ? -1 : d[cr]); + } + + cout << ans << '\n'; +} diff --git a/kjhonggg95/baekjoon/12886.cpp b/kjhonggg95/baekjoon/12886.cpp new file mode 100644 index 0000000..a6d0581 --- /dev/null +++ b/kjhonggg95/baekjoon/12886.cpp @@ -0,0 +1,80 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +bool vis[2005][2005]; + +struct stone +{ + int a; + int b; + int c; +}; + +int main() +{ + fastio; + int A, B, C; + cin >> A >> B >> C; + + queue q; + q.push({A, B, C}); + vis[A][B] = true; + vis[B][C] = true; + + while (!q.empty()) + { + int a = q.front().a; + int b = q.front().b; + int c = q.front().c; + q.pop(); + + if (a == b && b == c) + { + cout << 1 << '\n'; + return 0; + } + + // a b + if (a > b && !vis[a - b][b + b]) + { + q.push({a - b, b + b, c}); + vis[a - b][b + b] = true; + } + else if (a < b && !vis[a + a][b - a]) + { + q.push({a + a, b - a, c}); + vis[a + a][b - a] = true; + } + + // b c + if (b > c && !vis[b - c][c + c]) + { + q.push({a, b - c, c + c}); + vis[b - c][c + c] = true; + } + else if (b < c && !vis[b + b][c - b]) + { + q.push({a, b + b, c - b}); + vis[b + b][c - b] = true; + } + + // c a + if (c > a && !vis[a + a][c - a]) + { + q.push({a + a, b, c - a}); + vis[a + a][c - a] = true; + } + else if (c < a && !vis[a - c][c + c]) + { + q.push({a - c, b, c + c}); + vis[a - c][c + c] = true; + } + } + + cout << 0 << '\n'; +} diff --git a/kjhonggg95/baekjoon/12908.cpp b/kjhonggg95/baekjoon/12908.cpp new file mode 100644 index 0000000..319752b --- /dev/null +++ b/kjhonggg95/baekjoon/12908.cpp @@ -0,0 +1,41 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +// 정점 8개 + +ll dist[10][10]; + +vector v; + +int main() +{ + fastio; + vector v(9); + for(int i = 1;i <= 8;i++) + for(int j = 1;j <= 8;j++) + dist[i][j] = LLONG_MAX; + + cin >> v[1].X >> v[1].Y >> v[2].X >> v[2].Y; + + for(int i = 3;i <= 7;i += 2) + { + cin >> v[i].X >> v[i].Y >> v[i + 1].X >> v[i + 1].Y; + dist[i][i + 1] = dist[i + 1][i] = 10; + } + + for(int i = 1;i <= 8;i++) + for(int j = 1;j <= 8;j++) + dist[i][j] = min(dist[i][j], abs(v[i].X - v[j].X) + abs(v[i].Y - v[j].Y)); + + for(int k = 1;k <= 8;k++) + for(int i = 1;i <= 8;i++) + for(int j = 1;j <= 8;j++) + dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); + + cout << dist[1][2] << '\n'; +} diff --git a/kjhonggg95/baekjoon/14497.cpp b/kjhonggg95/baekjoon/14497.cpp new file mode 100644 index 0000000..3144355 --- /dev/null +++ b/kjhonggg95/baekjoon/14497.cpp @@ -0,0 +1,62 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int dx[4] = {1, 0, -1, 0}; +int dy[4] = {0, 1, 0, -1}; + +int arr[301][301]; +int d[301][301]; + +int main() +{ + fastio; + int n, m, x1, y1, x2, y2; + cin >> n >> m >> x1 >> y1 >> x2 >> y2; + x1--; y1--; x2--; y2--; + for (int i = 0; i < n; i++) + { + string s; + cin >> s; + for (int j = 0; j < m; j++) + { + if (s[j] == '#' || s[j] == '*' || s[j] == '0') + arr[i][j] = 0; + else + arr[i][j] = 1; + d[i][j] = 1e9; + } + } + + priority_queue , vector >, greater >> pq; + + d[x1][y1] = 0; + pq.push({d[x1][y1], {x1, y1}}); + + while (!pq.empty()) + { + auto w = pq.top().X; + auto cur = pq.top().Y; + pq.pop(); + + if (d[cur.X][cur.Y] != w) + continue; + + for (int dir = 0; dir < 4; dir++) + { + int nx = cur.X + dx[dir]; + int ny = cur.Y + dy[dir]; + + if (nx < 0 || nx >= n || ny < 0 || ny >= m) continue; + if (d[nx][ny] <= d[cur.X][cur.Y] + arr[nx][ny]) continue; + d[nx][ny] = d[cur.X][cur.Y] + arr[nx][ny]; + pq.push({d[nx][ny], {nx, ny}}); + } + } + + cout << d[x2][y2] + 1 << '\n'; +} diff --git a/kjhonggg95/baekjoon/14597.cpp b/kjhonggg95/baekjoon/14597.cpp new file mode 100644 index 0000000..3569297 --- /dev/null +++ b/kjhonggg95/baekjoon/14597.cpp @@ -0,0 +1,50 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int arr[105][105]; +int dp[105][105]; + +int main() +{ + fastio; + int n, m, x, ans = 1e9; + cin >> n >> m; + for(int i = 1; i <= n;i++) + for(int j = 1;j <= m;j++) + cin >> arr[i][j]; + + for(int i = 1; i <= n;i++) + for(int j = 1;j <= m;j++) + { + cin >> x; + arr[i][j] = (arr[i][j] - x) * (arr[i][j] - x); + if(i == 1) dp[i][j] = arr[i][j]; + } + + for(int i = 2;i <= n;i++) + { + for(int j = 1;j <= m;j++) + { + if(m >= 2) + { + if(j == 1) + dp[i][j] = min(dp[i - 1][j], dp[i - 1][j + 1]) + arr[i][j]; + else if(j == m) + dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j]) + arr[i][j]; + else + dp[i][j] = min({dp[i - 1][j - 1], dp[i - 1][j], dp[i - 1][j + 1]}) + arr[i][j]; + } + else + dp[i][j] = dp[i - 1][j] + arr[i][j]; + } + } + + for(int j = 1;j <= m;j++) + ans = min(ans, dp[n][j]); + cout << ans << '\n'; +} diff --git a/kjhonggg95/baekjoon/14618.cpp b/kjhonggg95/baekjoon/14618.cpp new file mode 100644 index 0000000..7243dda --- /dev/null +++ b/kjhonggg95/baekjoon/14618.cpp @@ -0,0 +1,90 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +#define A 1 +#define B 2 +#define INF 1e9 + +int n, m, j, k, x, u, v, w; +int d[5005]; + +map house; + +vector adj[5005]; + +int main() +{ + fastio; + cin >> n >> m >> j >> k; + fill(d, d + n + 1, INF); + + // A형 집 + for(int i = 0;i > x; + house[x] = A; + } + + // B형 집 + for(int i = 0;i > x; + house[x] = B; + } + + while(m--) + { + cin >> u >> v >> w; + adj[u].push_back({w, v}); + adj[v].push_back({w, u}); + } + + priority_queue , greater > pq; + + d[j] = 0; + pq.push({d[j], j}); + + while(!pq.empty()) + { + auto cur = pq.top(); + pq.pop(); + + if(d[cur.Y] != cur.X) continue; + + for(auto nxt : adj[cur.Y]) + { + if(d[nxt.Y] <= d[cur.Y] + nxt.X) continue; + d[nxt.Y] = d[cur.Y] + nxt.X; + + pq.push({d[nxt.Y], nxt.Y}); + } + } + + int min_dist = INF - 1; + int ans = -1; + + for(int i = 1;i<=n;i++) + { + if(house[i] == B && d[i] < min_dist) + { + ans = B; + min_dist = d[i]; + } + + if(house[i] == A && d[i] <= min_dist) + { + ans = A; + min_dist = d[i]; + } + } + + if(ans == -1) + cout << ans << '\n'; + else + cout << (ans == A ? 'A' : 'B') << '\n' << min_dist << '\n'; +} diff --git a/kjhonggg95/baekjoon/14658.cpp b/kjhonggg95/baekjoon/14658.cpp new file mode 100644 index 0000000..9c58c2d --- /dev/null +++ b/kjhonggg95/baekjoon/14658.cpp @@ -0,0 +1,31 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int n, m, l, k, mx; + +int main() +{ + fastio; + cin >> n >> m >> l >> k; + vector star(k); + for(int i = 0;i > star[i].X >> star[i].Y; + + for(auto& a : star) + { + for(auto& b : star) + { + int x = a.X, y = b.Y, cnt = 0; + for(auto& e : star) + if(e.X >= x && e.X <= x + l && e.Y >= y && e.Y <= y + l) cnt++; + mx = max(mx, cnt); + } + } + + cout << k - mx << '\n'; +} diff --git a/kjhonggg95/baekjoon/14718.cpp b/kjhonggg95/baekjoon/14718.cpp new file mode 100644 index 0000000..9beaad9 --- /dev/null +++ b/kjhonggg95/baekjoon/14718.cpp @@ -0,0 +1,37 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int str[101]; +int dex[101]; +int inte[101]; + +int main() +{ + fastio; + int n, K, ans = 1e9; + cin >> n >> K; + for(int i = 0;i > str[i] >> dex[i] >> inte[i]; + + for(int i = 0;i = str[l] && dex[j] >= dex[l] && inte[k] >= inte[l]) cnt++; + if(cnt >= K) + ans = min(ans, str[i] + dex[j] + inte[k]); + } + } + } + + cout << ans << '\n'; +} diff --git a/kjhonggg95/baekjoon/14722.cpp b/kjhonggg95/baekjoon/14722.cpp new file mode 100644 index 0000000..eef6a4b --- /dev/null +++ b/kjhonggg95/baekjoon/14722.cpp @@ -0,0 +1,59 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int n; +int arr[1001][1001]; +pii dp[1001][1001]; // [i][j] : i, j 칸에 도달했을 때 {최근에 마신 우유, 지금까지 마신 우유의 수} + +// 0 딸기우유 +// 1 초코우유 +// 2 바나나우유 + +// 딸기 -> 초코 -> 바나나 -> 딸기 -> ... + +// 이동 +// 1) 동쪽 +// 2) 남쪽 + +pii func(int r, int c) +{ + if (r <= 0 || c <= 0) + return {-1e9, -1e9}; + + if (dp[r][c].Y != -1) + return dp[r][c]; + + // 위쪽 + pii ret1 = func(r - 1, c); + if (arr[r][c] == (dp[r - 1][c].X + 1) % 3) + ret1 = {arr[r][c], dp[r-1][c].Y + 1}; + + // 왼쪽 + pii ret2 = func(r, c - 1); + if (arr[r][c] == (dp[r][c - 1].X + 1) % 3) + ret2 = {arr[r][c], dp[r][c - 1].Y + 1}; + + return dp[r][c] = (ret1.Y > ret2.Y ? ret1 : ret2); +} + +int main() +{ + fastio; + memset(dp, -1, sizeof(dp)); + cin >> n; + for (int i = 1; i <= n; i++) + for (int j = 1; j <= n; j++) + cin >> arr[i][j]; + + dp[1][1] = {2, 0}; + + if(arr[1][1] == 0) + dp[1][1] = {0, 1}; + + cout << func(n, n).Y << '\n'; +} diff --git a/kjhonggg95/baekjoon/14925.cpp b/kjhonggg95/baekjoon/14925.cpp new file mode 100644 index 0000000..a25eb94 --- /dev/null +++ b/kjhonggg95/baekjoon/14925.cpp @@ -0,0 +1,32 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int arr[1001][1001]; +int dp[1001][1001]; + +int main() +{ + fastio; + int n, m, ans = 0; + cin >> n >> m; + for (int i = 1; i <= n; i++) + for (int j = 1; j <= m; j++) + cin >> arr[i][j]; + + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= m; j++) + { + if (arr[i][j] != 0) continue; + dp[i][j] = min({dp[i - 1][j], dp[i - 1][j - 1], dp[i][j - 1]}) + 1; + ans = max(ans, dp[i][j]); + } + } + + cout << ans << '\n'; +} diff --git a/kjhonggg95/baekjoon/14945.cpp b/kjhonggg95/baekjoon/14945.cpp new file mode 100644 index 0000000..7bacb27 --- /dev/null +++ b/kjhonggg95/baekjoon/14945.cpp @@ -0,0 +1,27 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int dp[101][101]; + +int main() +{ + fastio; + int n, ans = 0; + cin >> n; + + dp[2][1] = 2; // 2층 + + for(int i = 3;i <= n;i++) + for(int j = 1;j <= n - 1;j++) + dp[i][j] = (dp[i - 1][j] * 2 + dp[i - 1][j - 1] + dp[i - 1][j + 1]) % 10007; + + for(int j = 1;j <= n - 1;j++) + ans = (ans + dp[n][j]) % 10007; + + cout << ans << '\n'; +} diff --git a/kjhonggg95/baekjoon/15809.cpp b/kjhonggg95/baekjoon/15809.cpp new file mode 100644 index 0000000..98a5d67 --- /dev/null +++ b/kjhonggg95/baekjoon/15809.cpp @@ -0,0 +1,102 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int n, m, a, o, p, q; +int par[100001]; +int arr[100001]; +bool live[100001]; + +// find +int find(int u) +{ + if(par[u] < 0) return u; + return par[u] = find(par[u]); +} + +// 동맹 +void align(int u, int v) +{ + u = find(u); + v = find(v); + + if(u < v) + { + par[v] = u; + arr[u] += arr[v]; + live[v] = false; + } + else + { + par[u] = v; + arr[v] += arr[u]; + live[u] = false; + } +} + +// 속국 +void merge(int u, int v) +{ + u = find(u); + v = find(v); + + if(u == v) return; + + par[v] = u; +} + +int main() +{ + fastio; + memset(par, -1, sizeof(par)); + memset(live, true, sizeof(live)); + cin >> n >> m; + for(int i = 1;i<=n;i++) + cin >> arr[i]; + + while(m--) + { + cin >> o >> p >> q; + + if(o == 1) // 동맹 + align(p, q); + else if(o == 2) // 전쟁 + { + p = find(p); + q = find(q); + + if(arr[p] == arr[q]) + { + arr[p] = arr[q] = 0; + live[p] = live[q] = false; + } + else + { + int winner = (arr[p] > arr[q] ? p : q); + int loser = (arr[p] > arr[q] ? q : p); + + arr[winner] = arr[winner] - arr[loser]; + live[loser] = false; + + merge(winner, loser); + } + } + } + + vector ans; + for(int i = 1;i<=n;i++) + if(live[i]) + ans.push_back(arr[i]); + + sort(ans.begin(), ans.end()); + + cout << ans.size() << '\n'; + + for(auto e : ans) + cout << e << ' '; + cout << '\n'; +} diff --git a/kjhonggg95/baekjoon/15924.cpp b/kjhonggg95/baekjoon/15924.cpp new file mode 100644 index 0000000..4a32d6d --- /dev/null +++ b/kjhonggg95/baekjoon/15924.cpp @@ -0,0 +1,49 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +const int mod = 1000000009; + +char arr[3005][3005]; +ll dp[3005][3005]; + +int main() +{ + fastio; + int n, m; + cin >> n >> m; + for(int i = 1;i <= n;i++) + { + string s; + cin >> s; + for(int j = 1;j <= m;j++) + arr[i][j] = s[j - 1]; + } + + for(int i = 1;i <= n;i++) + { + for(int j = 1;j <= m;j++) + { + dp[i][j]++; // 해당 위치에서 탐색 시작 + if(arr[i][j] == 'E') // 오른쪽 + { + dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod; + } + else if(arr[i][j] == 'S') // 아래쪽 + { + dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod; + } + else if(arr[i][j] == 'B') // 오른쪽, 아래쪽 + { + dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod; + dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod; + } + } + } + + cout << dp[n][m] % mod << '\n'; +} diff --git a/kjhonggg95/baekjoon/16167.cpp b/kjhonggg95/baekjoon/16167.cpp new file mode 100644 index 0000000..9630225 --- /dev/null +++ b/kjhonggg95/baekjoon/16167.cpp @@ -0,0 +1,32 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +pii d[205][205]; // {거리, 거점 수} +int n, r, a, b, c, D, e; + +int main() +{ + fastio; + cin >> n >> r; + + for(int i = 1;i <= n;i++) for(int j = 1;j <= n;j++) + d[i][j] = (i == j) ? make_pair(0.0, 0.0) : make_pair(1e9, 1e9); + + while(r--) + { + cin >> a >> b >> c >> D >> e; + d[a][b] = {min(d[a][b].X, c + (e > 10 ? (e - 10) * D : 0)), 1}; + } + + for(int k = 1;k <= n;k++) for(int i = 1;i <= n;i++) for(int j = 1;j <= n;j++) + if(d[i][k].X + d[k][j].X < d[i][j].X || d[i][k].X + d[k][j].X == d[i][j].X && d[i][k].Y + d[k][j].Y < d[i][j].Y) + d[i][j] = {d[i][k].X + d[k][j].X, d[i][k].Y + d[k][j].Y}; + + if(d[1][n].X == 1e9) cout << "It is not a great way." ; + else cout << d[1][n].X << ' ' << d[1][n].Y + 1 << '\n'; +} diff --git a/kjhonggg95/baekjoon/16197.cpp b/kjhonggg95/baekjoon/16197.cpp new file mode 100644 index 0000000..520940d --- /dev/null +++ b/kjhonggg95/baekjoon/16197.cpp @@ -0,0 +1,115 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int dx[4] = {1, 0, -1, 0}; +int dy[4] = {0, 1, 0, -1}; + +char arr[25][25]; +bool vis[25][25][25][25]; +int n, m, ans; + +struct pos +{ + pii coin1; + pii coin2; + int cnt; +}; + +int main() +{ + fastio; + pii coin1, coin2; + int cnt = 0; + cin >> n >> m; + for (int i = 1; i <= n; i++) + { + string s; + cin >> s; + for (int j = 1; j <= m; j++) + { + arr[i][j] = s[j - 1]; + if (arr[i][j] == 'o') + { + if (cnt == 0) + { + coin1 = {i, j}; + cnt++; + } + else + coin2 = {i, j}; + } + } + } + + queue q; + q.push({coin1, coin2, 0}); // {동전1 위치, 동전2 위치, 이동 횟수} + vis[coin1.X][coin1.Y][coin2.X][coin2.Y] = true; + + while (!q.empty()) + { + auto c1 = q.front().coin1; // 동전1 위치 + auto c2 = q.front().coin2; // 동전2 위치 + auto cnt = q.front().cnt; // 이동 횟수 + q.pop(); + + // 두 동전의 위치가 겹치는 경우 -> 하나만 떨어뜨리기 불가능 + if(c1 == c2) + continue; + + // 버튼을 10번보다 많이 누른 경우 + if (cnt >= 11) + continue; + + // 둘 다 떨어지는 경우 + if((c1.X <= 0 || c1.X > n || c1.Y <= 0 || c1.Y > m) && (c2.X <= 0 || c2.X > n || c2.Y <= 0 || c2.Y > m)) + continue; + + // 동전1만 떨어지는 경우 + if ((c1.X <= 0 || c1.X > n || c1.Y <= 0 || c1.Y > m) && (c2.X > 0 && c2.X <= n && c2.Y > 0 && c2.Y <= m)) + { + cout << cnt << '\n'; + return 0; + } + + // 동전2만 떨어지는 경우 + if ((c2.X <= 0 || c2.X > n || c2.Y <= 0 || c2.Y > m) && (c1.X > 0 && c1.X <= n && c1.Y > 0 && c1.Y <= m)) + { + cout << cnt << '\n'; + return 0; + } + + for (int dir = 0; dir < 4; dir++) + { + int c1nx = c1.X + dx[dir]; + int c1ny = c1.Y + dy[dir]; + + int c2nx = c2.X + dx[dir]; + int c2ny = c2.Y + dy[dir]; + + if (arr[c1nx][c1ny] == '#') + { + c1nx = c1.X; + c1ny = c1.Y; + } + + if (arr[c2nx][c2ny] == '#') + { + c2nx = c2.X; + c2ny = c2.Y; + } + + if(vis[c1nx][c1ny][c2nx][c2ny] || vis[c2nx][c2ny][c1nx][c1ny]) continue; + + q.push({{c1nx, c1ny}, {c2nx, c2ny}, cnt + 1}); + vis[c1nx][c1ny][c2nx][c2ny] = true; + } + } + + cout << -1 << '\n'; + return 0; +} diff --git a/kjhonggg95/baekjoon/16569.cpp b/kjhonggg95/baekjoon/16569.cpp new file mode 100644 index 0000000..7b08457 --- /dev/null +++ b/kjhonggg95/baekjoon/16569.cpp @@ -0,0 +1,103 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int dx[4] = {1, 0, -1, 0}; +int dy[4] = {0, 1, 0, -1}; + +int h[101][101]; // 고도 +int t[101][101]; // 화산쇄설류로 뒤덮이는 시간 +bool volcano[101][101]; +int arrive[101][101]; +bool vis[101][101]; + +int n, m, v, x, y; + +int main() +{ + fastio; + cin >> n >> m >> v >> x >> y; + + // 화산의 고도 + for (int i = 1; i <= n; i++) + for (int j = 1; j <= m; j++) + { + cin >> h[i][j]; + t[i][j] = 1e9; + } + + queue > q; // {위치, 시간} + + while (v--) + { + int a, b, c; + cin >> a >> b >> c; + volcano[a][b] = true; + t[a][b] = c; + q.push({{a, b}, c}); + + while (!q.empty()) + { + auto cur = q.front().X; + auto time = q.front().Y; + q.pop(); + + for (int dir = 0; dir < 4; dir++) + { + int nx = cur.X + dx[dir]; + int ny = cur.Y + dy[dir]; + + if (nx <= 0 || nx > n || ny <= 0 || ny > m) continue; + if (t[nx][ny] <= t[cur.X][cur.Y] + 1) continue; + t[nx][ny] = time + 1; + q.push({{nx, ny}, time + 1}); + } + } + } + + q.push({{x, y}, 0}); // 재승 위치, 0초부터 시작 + vis[x][y] = true; + arrive[x][y] = 0; + + while (!q.empty()) + { + auto cur = q.front().X; + auto time = q.front().Y; + q.pop(); + + for (int dir = 0; dir < 4; dir++) + { + int nx = cur.X + dx[dir]; + int ny = cur.Y + dy[dir]; + + if (nx <= 0 || nx > n || ny <= 0 || ny > m) continue; + if (vis[nx][ny] || volcano[nx][ny] || time + 1 >= t[nx][ny]) continue; + + vis[nx][ny] = true; + arrive[nx][ny] = time + 1; + q.push({{nx, ny}, time + 1}); + } + } + + int maxh = h[x][y], mint = 1e9; + + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= m; j++) + { + if (!vis[i][j]) continue; + maxh = max(maxh, h[i][j]); + } + } + + for (int i = 1; i <= n; i++) + for (int j = 1; j <= m; j++) + if (vis[i][j] && h[i][j] == maxh) + mint = min(mint, arrive[i][j]); + + cout << maxh << ' ' << mint << '\n'; +} diff --git a/kjhonggg95/baekjoon/17305.cpp b/kjhonggg95/baekjoon/17305.cpp new file mode 100644 index 0000000..82b80df --- /dev/null +++ b/kjhonggg95/baekjoon/17305.cpp @@ -0,0 +1,50 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +vector a; +vector b; + +ll three[250001]; +ll five[250001]; + +int main() +{ + fastio; + int n, w; + cin >> n >> w; + while (n--) + { + int t, s; + cin >> t >> s; + if (t == 3) + a.push_back(s); + else + b.push_back(s); + } + + sort(a.begin(), a.end(), greater<>()); + sort(b.begin(), b.end(), greater<>()); + + for (int i = 0; i < a.size(); i++) + three[i + 1] = three[i] + a[i]; + + for (int i = 0; i < b.size(); i++) + five[i + 1] = five[i] + b[i]; + + int fiveCnt = min((int)b.size(), w / 5); // 최대 담을 수 있는 5g 짜리 사탕의 개수 -> 2 + ll sum = five[fiveCnt]; // 180 + + while(fiveCnt >= 0) + { + int threeCnt = min((int)a.size(), (w - 5 * fiveCnt) / 3); + sum = max(sum, five[fiveCnt] + three[threeCnt]); + fiveCnt--; + } + + cout << sum << '\n'; +} diff --git a/kjhonggg95/baekjoon/18188.cpp b/kjhonggg95/baekjoon/18188.cpp new file mode 100644 index 0000000..13b1400 --- /dev/null +++ b/kjhonggg95/baekjoon/18188.cpp @@ -0,0 +1,63 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int h, w, n; +char arr[21][21]; +char dir[21][2]; + +pii st; +string s, ans = "NO"; + +void dfs(int curR, int curC, int step, string cmd) +{ + if (step > n || curR <= 0 || curR > h || curC <= 0 || curC > w || arr[curR][curC] == '@') + return; + + if (arr[curR][curC] == 'Z') + { + ans = "YES\n" + cmd; + return; + } + + for (int i = 0; i < 2; i++) + { + if (dir[step][i] == 'W') + dfs(curR - 1, curC, step + 1, cmd + 'W'); + else if (dir[step][i] == 'A') + dfs(curR, curC - 1, step + 1, cmd + 'A'); + else if (dir[step][i] == 'S') + dfs(curR + 1, curC, step + 1, cmd + 'S'); + else if (dir[step][i] == 'D') + dfs(curR, curC + 1, step + 1, cmd + 'D'); + } +} + +int main() +{ + fastio; + cin >> h >> w; + for (int i = 1; i <= h; i++) + { + cin >> s; + for (int j = 1; j <= w; j++) + { + arr[i][j] = s[j - 1]; + if (arr[i][j] == 'D') + st = {i, j}; + } + } + + cin >> n; + + for (int i = 0; i < n; i++) + cin >> dir[i][0] >> dir[i][1]; + + dfs(st.X, st.Y, 0, ""); + + cout << ans << '\n'; +} diff --git a/kjhonggg95/baekjoon/18430.cpp b/kjhonggg95/baekjoon/18430.cpp new file mode 100644 index 0000000..51236e3 --- /dev/null +++ b/kjhonggg95/baekjoon/18430.cpp @@ -0,0 +1,57 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int n, m, ans; + +int dx[4] = {1, 1, -1, -1}; +int dy[4] = {1, -1, 1, -1}; + +int arr[5][5]; +bool vis[5][5]; + +void dfs(int r, int c, int sum) +{ + ans = max(ans, sum); + + if (c == m) + { + r++; + c = 0; + if (r == n) return; + } + + if (!vis[r][c]) + { + for (int dir = 0; dir < 4; dir++) + { + int nx = r + dx[dir]; + int ny = c + dy[dir]; + + if (nx < 0 || nx >= n || ny < 0 || ny >= m) continue; + if (vis[nx][c] || vis[r][ny]) continue; + + vis[r][c] = vis[nx][c] = vis[r][ny] = true; + dfs(r, c + 1, sum + arr[r][c] * 2 + arr[nx][c] + arr[r][ny]); + vis[r][c] = vis[nx][c] = vis[r][ny] = false; + } + } + + dfs(r, c + 1, sum); +} + +int main() +{ + fastio; + cin >> n >> m; + for (int i = 0; i < n; i++) + for (int j = 0; j < m; j++) + cin >> arr[i][j]; + + dfs(0, 0, 0); + cout << ans << '\n'; +} diff --git a/kjhonggg95/baekjoon/19538.cpp b/kjhonggg95/baekjoon/19538.cpp new file mode 100644 index 0000000..08b3a9a --- /dev/null +++ b/kjhonggg95/baekjoon/19538.cpp @@ -0,0 +1,62 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +vector adj[200001]; +int rumor[200001]; // 루머를 믿기 시작한 시간 +bool vis[200001]; +int n, m, x; + +int main() +{ + fastio; + memset(rumor, -1, sizeof(rumor)); + cin >> n; + for (int i = 1; i <= n; i++) + { + while (cin >> x) + { + if (x == 0) break; + adj[i].push_back(x); + } + } + + cin >> m; + + queue q; + while (m--) + { + cin >> x; + rumor[x] = 0; + vis[x] = true; + q.push({x, 0}); + } + + while (!q.empty()) + { + auto cur = q.front(); q.pop(); + rumor[cur.X] = cur.Y; + + for (auto& nxt : adj[cur.X]) + { + if (vis[nxt]) continue; + + int cnt = 0, sz = adj[nxt].size(); + for (auto& e : adj[nxt]) + cnt += (rumor[e] != -1); + + if(((sz & 1) && cnt <= sz / 2) || (!(sz & 1) && cnt < sz / 2)) continue; + + vis[nxt] = true; + q.push({nxt, cur.Y + 1}); + } + } + + for (int i = 1; i <= n; i++) + cout << rumor[i] << ' '; + cout << '\n'; +} diff --git a/kjhonggg95/baekjoon/19845.cpp b/kjhonggg95/baekjoon/19845.cpp new file mode 100644 index 0000000..006b44f --- /dev/null +++ b/kjhonggg95/baekjoon/19845.cpp @@ -0,0 +1,44 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int main() +{ + fastio; + int n, q; + cin >> n >> q; + vector v(n+1); + + // 중력의 영향을 받기 때문에 내림차순으로 입력이 들어온다 + for(int i = 1;i<=n;i++) + cin >> v[i]; + + while(q--) + { + int x, y; + cin >> x >> y; + + int wcnt = v[y] - x + 1; // 가로방향 레이저 + int hcnt = 0; // 세로방향 레이저 -> y층 이상에서 x 보다 크거나 같은 최대 층 구하기 + + int lo = y - 1, hi = n + 1; + + while(lo + 1 < hi) + { + int mid = (lo + hi) / 2; + + if(v[mid] >= x) + lo = mid; + else + hi = mid; + } + + hcnt = lo - y + 1; + + cout << max(0, wcnt + hcnt - 1) << '\n'; + } +} diff --git a/kjhonggg95/baekjoon/20924.cpp b/kjhonggg95/baekjoon/20924.cpp new file mode 100644 index 0000000..817127e --- /dev/null +++ b/kjhonggg95/baekjoon/20924.cpp @@ -0,0 +1,59 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int n, a, b, d, rr, gg, mxleaf; +vector g[200001]; // {dest, dist}; +bool vis[200001]; + +// 기둥 : root ~ giga +// 가지 : giga ~ leaf + +void dfs(int cur, int dist) +{ + mxleaf = max(mxleaf, dist); + + if (gg == 0 && g[cur].size() >= 3) + { + gg = cur; + return; + } + + for (auto nxt : g[cur]) + { + if (vis[nxt.X]) continue; + vis[nxt.X] = true; + dfs(nxt.X, dist + nxt.Y); + } +} + +int main() +{ + fastio; + cin >> n >> rr; + for (int i = 0; i < n - 1; i++) + { + cin >> a >> b >> d; + g[a].push_back({b, d}); + g[b].push_back({a, d}); + } + + // 기둥 + vis[rr] = true; + if(g[rr].size() >= 2) // 루트에서 바로 가지가 나오는 경우 + gg = rr; // 루트 == 기가 + else + dfs(rr, 0); + + cout << mxleaf << ' '; + mxleaf = 0; + + // 가지 + vis[gg] = true; + dfs(gg, 0); + cout << mxleaf << '\n'; +} diff --git a/kjhonggg95/baekjoon/2171.cpp b/kjhonggg95/baekjoon/2171.cpp new file mode 100644 index 0000000..7b32f3c --- /dev/null +++ b/kjhonggg95/baekjoon/2171.cpp @@ -0,0 +1,52 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +bool pos[5005][5005]; + +int main() +{ + fastio; + int n; + cin >> n; + vector xx(n); + vector yy(n); + for(int i = 0;i < n;i++) + cin >> xx[i] >> yy[i]; + + vector x(xx); + vector y(yy); + + sort(x.begin(), x.end()); + sort(y.begin(), y.end()); + + x.erase(unique(x.begin(), x.end()), x.end()); + y.erase(unique(y.begin(), y.end()), y.end()); + + vector v(n); + + for(int i = 0;i < n;i++) + { + int xxx = lower_bound(x.begin(), x.end(), xx[i]) - x.begin(); + int yyy = lower_bound(y.begin(), y.end(), yy[i]) - y.begin(); + pos[xxx][yyy] = true; + v[i] = {xxx, yyy}; + } + + int cnt = 0; + + for(int i = 0;i < n;i++) + { + for(int j = 0;j < n;j++) + { + if(v[i].X >= v[j].X || v[i].Y >= v[j].Y) continue; + if(pos[v[i].X][v[j].Y] && pos[v[j].X][v[i].Y]) cnt++; + } + } + + cout << cnt << '\n'; +} diff --git a/kjhonggg95/baekjoon/25319.cpp b/kjhonggg95/baekjoon/25319.cpp new file mode 100644 index 0000000..d7027aa --- /dev/null +++ b/kjhonggg95/baekjoon/25319.cpp @@ -0,0 +1,170 @@ +#include +#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) +#define X first +#define Y second +using namespace std; +using ll = long long; +using pii = pair ; + +int dx[4] = {1, 0, -1, 0}; +int dy[4] = {0, 1, 0, -1}; + +int n, m, l, mx_c; +string s; + +char arr[51][51]; +int freq[26]; +bool vis[51][51]; + +vector