Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

68-tgyuuAn #226

Merged
merged 2 commits into from
Aug 20, 2024
Merged

68-tgyuuAn #226

merged 2 commits into from
Aug 20, 2024

Conversation

tgyuuAn
Copy link
Member

@tgyuuAn tgyuuAn commented Aug 6, 2024

๐Ÿ”— ๋ฌธ์ œ ๋งํฌ

๊ฐ€ํฌ์™€ ํƒ‘

โœ”๏ธ ์†Œ์š”๋œ ์‹œ๊ฐ„

3~40๋ถ„...? ๊ธฐ์–ต์ด ์•ˆ๋‚จ..

โœจ ์ˆ˜๋„ ์ฝ”๋“œ

image

๋ฌธ์ œ๋ž‘ ์ „ํ˜€ ๊ด€๋ จ ์—†๋Š” ์‚ฌ์ง„ ์ž…๋‹ˆ๋‹ค.




๋ฌธ์ œ๋Š” ๋งค์šฐ ์‰ฝ์Šต๋‹ˆ๋‹ค.

์•„๋ž˜์™€ ๊ฐ™์ด ๊ฐ€ํฌ์™€ ๋‹จ๋น„๊ฐ€ ์˜ค๋ฅธ์ชฝ, ์™ผ์ชฝ ๋์— ์œ„์น˜ํ•ด์žˆ์œผ๋ฉฐ,

๋‘ ๋ช… ์‚ฌ์ด์— ๊ฑด๋ฌผ N๊ฐœ๊ฐ€ ์žˆ์–ด์š”.

image




๊ทผ๋ฐ ์ด์ œ ๊ฐ€ํฌ๋Š” ์™ผ์ชฝ์—์„œ๋ถ€ํ„ฐ a๊ฐœ๋งŒ ๋ณผ ์ˆ˜ ์žˆ๊ณ ,

๋‹จ๋น„๋Š” ์˜ค๋ฅธ์ชฝ์—์„œ b๊ฐœ๋งŒ ๋ณผ ์ˆ˜ ์žˆ์–ด์š”.

์•ฝ๊ฐ„ ๊ณ„๋‹จ ๋Š๋‚Œ ์ƒ๊ฐํ•˜๋ฉด ์ข‹์„๋“ฏํ•ฉ๋‹ˆ๋‹ค.

image




์จ‹๋“  ์œ„ ์กฐ๊ฑด์„ ๋งŒ์กฑ์‹œํ‚ฌ ๊ฒฝ์šฐ์˜ ์ˆ˜๋Š” ๋˜๊ฒŒ ๋งŽ์€๋ฐ,

์–ด๋–ค ์ˆ˜๊ฐ€ ์™€๋„ ์ข‹๊ณ  ์ค‘๋ณต๋˜๋Š” ์ˆ˜๊ฐ€ ์™€๋„ ์ข‹์œผ๋‹ˆ ์‚ฌ์ „์ˆœ์œผ๋กœ ๊ฐ€์žฅ ์•ž์„  ๊ฒฝ์šฐ ๋ฅผ ์ถœ๋ ฅํ•ด๋‹ฌ๋ผ๊ณ ํ•˜๋„ค์š”.







๋ฌธ์ œ๋งŒ ์ฝ๊ณ  ๊ฐ ์˜ค์‹œ๋‚˜์š” ?!?!?!?!???

์‚ฌ์ „์ˆœ์œผ๋กœ ๊ฐ€์žฅ ์•ž์„  ๊ฒฝ์šฐ ์ด๊ธฐ ๋•Œ๋ฌธ์—, ์™ผ์ชฝ์—๋Š” ์ตœ๋Œ€ํ•œ ์ž‘์€ ์ˆซ์ž๋งŒ ๋ฐฐ์น˜ํ•˜๊ณ ,

์˜ค๋ฅธ์ชฝ์œผ๋กœ ์ตœ๋Œ€ํ•œ ํฐ ์ˆซ์ž๋“ค์„ ๋ฐ€์–ด์•ผํ•ด์š”.







์˜ˆ๋ฅผ๋“ค์–ด ๊ฑด๋ฌผ์ด ์ด 7๊ฐœ๊ฐ€ ์žˆ๊ณ ,

์™ผ์ชฝ์—์„œ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ๊ฑด๋ฌผ 3๊ฐœ๊ฐ€ ๋ณด์ด๋ฉฐ ์˜ค๋ฅธ์ชฝ์—์„œ ์™ผ์ชฝ์€ 2๊ฐœ๊ฐ€ ๋ณด์ธ๋‹ค๊ณ  ํ•ด๋ณผ๊ฒŒ์š”.

input : 7 3 2

๊ทธ๋Ÿผ ์ด ๋•Œ ์™ผ์ชฝ์—์„œ ๋ณด์ด๋Š” ๊ฑด๋ฌผ์˜ ๊ฐœ์ˆ˜๊ฐ€ ์˜ค๋ฅธ์ชฝ์—์„œ ๋ณด์ด๋Š” ๊ฑด๋ฌผ์˜ ๊ฐœ์ˆ˜๋ณด๋‹ค ๋” ํฌ๋ฏ€๋กœ,

์™ผ์ชฝ์—์„œ ๋ณด์ด๋Š” ๊ฑด๋ฌผ ๊ฐœ์ˆ˜๋ถ€ํ„ฐ ์ผ๋ ฌ๋กœ ์„ธ์›Œ์š”.

๊ทผ๋ฐ ์–ด๋””๋ถ€ํ„ฐ ์„ธ์šฐ๋ƒ?

์™ผ์ชฝ๋๋ถ€ํ„ฐ 1 2 3 0 0 0 0 ์œผ๋กœ ์„ธ์šฐ๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ,

0 0 0 1 2 3 0 ์œผ๋กœ ์ตœ๋Œ€ํ•œ ์™ผ์ชฝ์œผ๋กœ ๋ฐ€์–ด์„œ ์„ธ์›Œ์ค๋‹ˆ๋‹ค.







๋’ค์— ํ•œ ์นธ์€ ์™œ ๋น„์šฐ๋ƒ๊ณ ์š” ?

๋‹จ๋น„๋„ ๊ฑด๋ฌผ 2๊ฐœ ๋ด์•ผ ๋˜์ž–์•„์š”!!!

๋‹จ๋น„๋„ ๋ณด์ด๋Š” ๊ฑด๋ฌผ ํ•˜๋‚˜ ์„ธ์›Œ์ค„๊ฒŒ์š”.

๊ทธ๋ƒฅ ์„ธ์šฐ๋Š” ๊ฑฐ ์•„๋‹ˆ๊ณ  ์‚ฌ์ „ ์ˆœ์œผ๋กœ ๊ฐ€์žฅ ์•ž์„  ๊ฒƒ ์„ ์„ธ์›Œ์•ผ ํ•˜๋ฏ€๋กœ 1๋ถ€ํ„ฐ ๋”ฐ๋ผ๋ž€ ์„ธ์›Œ์ค๋‹ˆ๋‹ค

0 0 0 1 2 3 1







์ด์ œ ์กฐ๊ฑด์ด ๋ชจ๋‘ ์ถฉ์กฑ๋˜์—ˆ์œผ๋‹ˆ ๋‚จ์€ ์นธ์— 1๋กœ ๊ฐ€๋“ ์ฑ„์›Œ์ฃผ๋ฉด ๋์ž…๋‹ˆ๋‹ค!

1 1 1 1 2 3 1







์‰ฝ์ฃ  ?!







๊ทผ๋ฐ ์ด ๊นŒ์ง€๋งŒ ํ•˜๋ฉด ํ‹€๋ฆฝ๋‹ˆ๋‹ค.

์ œ๊ฐ€ ๊ทธ๋ ‡๊ฒŒ ํ‹€๋ ค์„œ ๋ฐ˜๋ ˆ๋ฅผ ๋ชป์ฐพ์•„์„œ ๊ฒŒ์‹œํŒ์„ ๋’ค์กŒ์–ด์š”.

๋ฐ˜๋ก€๊ฐ€ ๋ฌด์—‡์ด๋ƒํ•˜๋ฉด,

7 1 3 ๊ณผ ๊ฐ™์€ ๊ฒฝ์šฐ์—์š”.

์˜ค๋ฅธ์ชฝ์—์„œ ๋ณด์ด๋Š” ๊ฑด๋ฌผ์˜ ๊ฐœ์ˆ˜๊ฐ€ 1๊ฐœ ๋ฐ–์— ์—†์„๋•Œ,

์™ผ์ชฝ์œผ๋กœ ์ด ์ˆ˜๋ฅผ ๋ฐ€ ์ˆ˜๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.







์™ผ์ชฝ์œผ๋กœ ๋ฐ€๊ฒŒ๋˜๋ฉด 1 1 1 1 3 2 1 ๊ฐ€ ๋˜๋Š”๋ฐ ์™ผ์ชฝ์—์„œ ๊ฑด๋ฌผ 2๊ฐœ๊ฐ€ ๋ณด์—ฌ์š”.

๊ทธ๋ž˜์„œ ์ด ์˜ค๋ฅธ์ชฝ์—์„œ 1๊ฐœ๋งŒ ๋ณด์ด๋Š” EdgeCase์—์„œ๋งŒ 0๋ฒˆ์งธ ํ•ญํ•˜๊ณ  ๊ฐ€์žฅ ํฐ ์ˆซ์ž ํ•ญ์„ ๋ฐ”๊ฟ”์ฃผ๋ฉด ๋˜์–ด์š”.

3 1 1 1 1 2 1

๋!!!!!

๐Ÿ“š ์ƒˆ๋กญ๊ฒŒ ์•Œ๊ฒŒ๋œ ๋‚ด์šฉ

@tgyuuAn tgyuuAn added tgyuuAn ํ•œ ์ค„๋กœ๋Š” ์†Œ๊ฐœํ•  ์ˆ˜ ์—†๋Š” ๋‚จ์ž. ์ž‘์„ฑ ์ค‘ โฑ๏ธ labels Aug 6, 2024
@tgyuuAn tgyuuAn self-assigned this Aug 6, 2024
@tgyuuAn tgyuuAn marked this pull request as ready for review August 6, 2024 13:48
Copy link

@InSange InSange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ฑด๋ฌผ์ด ๋ณด์ด๊ฒŒ๋” ์„ธ์›Œ์ฃผ๊ธฐ๋งŒ ํ•˜๋ฉด ๋  ์ค„ ์•Œ์•˜๋Š”๋ฐ ๋ชจ๋“  ๊ฑด๋ฌผ์˜ ๋†’์ด๋Š” ๊ธฐ๋ณธ 1์ด์ƒ์ด์–ด์•ผ ํ•œ๋‹ค๋Š” ์ ์—์„œ ๋‹ค ์„ธ์›Œ๋†“๊ณ  ๋†’์—ฌ์ฃผ๊ธฐ๋งŒ ํ•˜๋ฉด ๋˜๊ฒ ๊ตฌ๋‚˜ ์‹ถ์—ˆ์Šต๋‹ˆ๋‹ค.
๊ฐ€ํฌ๊ฐ€ ๋ณด์€ ๊ฑด๋ฌผ์˜ ์ˆ˜๊ฐ€ ๋‹จ๋น„๋ณด๋‹ค ๋†’์„ ๊ฒฝ์šฐ ๊ฐ€ํฌ ์ชฝ์„ ๋จผ์ € ๋†’์ด๋Š” ์‹์œผ๋กœ ๊ณ„์‚ฐํ•ด์ฃผ๋Š” ๋ฐฉ์‹ ์ž˜ ๋ดค์Šต๋‹ˆ๋‹ค. 0 ~ a๊ฐœ ๊นŒ์ง€ ์ง„ํ–‰ํ•˜๋Š”๋ฐ idx + 1๋กœ ํ•˜๊ฒŒ๋˜๋ฉด 1,2,3,4, ... a๊นŒ์ง€ ์„ธ์›Œ์ง€๋Š”๋ฐ 1์€ ๋งจ ์™ผ์ชฝ์—์„œ ๊ธฐ๋ณธ ๊ฐ’์œผ๋กœ ๋ณด์—ฌ์ง€๊ธฐ ๋•Œ๋ฌธ์— ์ƒ๊ด€์—†๋Š” ๋””ํ…Œ์ผ๊นŒ์ง€ ์ž˜ ๋ณด์•˜์Šต๋‹ˆ๋‹ค.

Copy link
Collaborator

@H0ngJu H0ngJu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ €๋Š” ํ‘ธ๋Š”๋ฐ ์‹œ๊ฐ„์ด ์ชผ๋งค ๊ฑธ๋ ธ์”๋‹ˆ๋‹ค.
๊ฐ€ํฌ > ๋‹จ๋น„ ์ผ๋•Œ๋Š” ์‰ฝ๊ฒŒ ๊ตฌํ˜„๋๋Š”๋ฐ
๋‹จ๋น„ > ๊ฐ€ํฌ ์ผ๋•Œ๋ž‘, ๋‹จ๋น„>๊ฐ€ํฌ ์ด๋ฉด์„œ ๊ฐ€ํฌ๊ฐ€ 1์ธ ๊ฒฝ์šฐ์— ๋Œ€ํ•ด์„œ ์ฒ˜๋ฆฌํ•˜๋Š๋ผ ์ €๋„ ์งˆ๋ฌธ ๊ฒŒ์‹œํŒ ์ผ€์ด์Šค๋ฅผ ๋’ค์กŒ๋„ค์š” ํ—ˆํ—ˆ

์ €๋Š” enumerate๋กœ ์‰ฝ๊ฒŒ ๋ฐ˜๋ณต๋ฌธ ๋Œ๋ฆฌ๋Š” ๊ฒƒ๋„ ์ธ์ƒ ๊นŠ์—ˆ์Šต๋‹ˆ๋‹ค!!
์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹น ~~

image

import sys

def input() : return sys.stdin.readline().rstrip()

N, a, b = map(int, input().split())
buildings = [1 for _ in range(N)]
f = b if a < b else a

if N+1<a+b: print(-1)
else:
    if f == a:
        if N == a:
            for i in range(N):
                buildings[i] += i
        else:
            k = 0
            for i in range(N-a-b+1, N-b+1):
                buildings[i] += k
                k += 1
            k = 0
            for i in range(N-1, N-b, -1):
                buildings[i] += k
                k += 1
    else:
        if N == b:
            k = 0
            for i in range(N-1, -1, -1):
                buildings[i] += k
                k += 1
        else:
            if a == 1:
                buildings[0] = b
                k = 0
                for i in range(N-1, N-b, -1):
                    buildings[i] += k
                    k += 1
            else:
                k = 0
                for i in range(N-1, N-b-1, -1):
                    buildings[i] += k
                    k += 1
                k = a - 2
                for i in range(N-b-1, N-b-a, -1):
                    buildings[i] = k + 1
                    k -= 1
    print(*buildings)

answer = [0 for _ in range(N)]

if a>b:
for idx, element in enumerate(range(N-a-b+1, N-b+1)):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aใ… enumerate ํ•จ์ˆ˜ ์“ฐ๋ฉด ์ธ๋ฑ์Šค๋ž‘ ๊ฐ’์œผ๋กœ ์‰ฝ๊ฒŒ ๊ตฌํ•  ์ˆ˜ ์žˆ๊ตฐ์š” .. ใ„ทใ„ท

@tgyuuAn tgyuuAn removed the request for review from seongwon030 August 20, 2024 15:21
@tgyuuAn tgyuuAn merged commit ae7f20b into main Aug 20, 2024
2 checks passed
@tgyuuAn tgyuuAn deleted the 68-tgyuuAn branch August 20, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tgyuuAn ํ•œ ์ค„๋กœ๋Š” ์†Œ๊ฐœํ•  ์ˆ˜ ์—†๋Š” ๋‚จ์ž. ๋ฆฌ๋ทฐ ์™„๋ฃŒ โœ”๏ธ
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants