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

30-SeongHoonC #215

Merged
merged 1 commit into from
Jul 14, 2024
Merged

30-SeongHoonC #215

merged 1 commit into from
Jul 14, 2024

Conversation

SeongHoonC
Copy link
Collaborator

πŸ”— 문제 링크

μ•”ν˜Έ λ§Œλ“€κΈ°

βœ”οΈ μ†Œμš”λœ μ‹œκ°„

30λΆ„

✨ μˆ˜λ„ μ½”λ“œ

음 λ³„λ‘œ 어렡진 μ•Šμ•˜λŠ”λ° 문제λ₯Ό μ œλŒ€λ‘œ μ•ˆμ½μ–΄μ„œ λͺ‡ 번 ν‹€λ Έλ„€μš”..ν•˜ν•˜

정렬을 λ¨Όμ € ν•˜κ³ ...
λͺ¨λ“  경우의수λ₯Ό νƒμƒ‰ν•˜λ‹€κ°€ κ°œμˆ˜κ°€ κ°™μœΌλ©΄ μ΅œμ†Œ 개수λ₯Ό λ§Œμ‘±ν•˜λŠ”μ§€ ν™•μΈν•˜κ³  좜λ ₯ν•©λ‹ˆλ‹€!

private lateinit var letters: List<String>

fun main() {
    val br = System.`in`.bufferedReader()
    val (l, c) = br.readLine().split(" ").map { it.toInt() }
    letters = br.readLine().split(" ").sorted()

    for (i in 0..c - l) {
        dfs(i, letters[i], l)
    }
}

private fun dfs(index: Int, word: String, l: Int) {
    if (word.length == l) {
        val counts = "aeiou".toList().count { word.contains(it) }
        if (counts > 0 && l - counts > 1) {
            println(word)
        }
        return
    }
    for (i in index + 1 until letters.size) {
        dfs(i, word + letters[i], l)
    }
}

πŸ“š μƒˆλ‘­κ²Œ μ•Œκ²Œλœ λ‚΄μš©

Copy link
Member

@tgyuuAn tgyuuAn left a comment

Choose a reason for hiding this comment

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

저도 문제 μ œλŒ€λ‘œ μ•ˆ 읽고 ν’€λ‹€κ°€ μ•žμ— 2번 ν‹€λ Έλ„€μš”..

μ½”ν…Œμ—μ„œ 이러면 μ•ˆλ˜λŠ”λ° 말이죠............

μ €λŠ” 파이썬 사기 λ©”μ†Œλ“œ Itertools μ‚¬μš©ν•΄μ„œ ν’€μ—ˆμ”λ‹ˆλ‹€!!!

pr이 λŠ¦μ–΄μ„œ μ£„μ†‘ν•©λ‹ˆλ‹€. λ°”λ‘œμ˜¬λ¦΄κ²Œμš”...!

import sys
from itertools import combinations

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

L, C = map(int, input().split())
word = list(input().split())
consonants = []
vowels = []

for char in sorted(word):
    if char in ("a", "e", "i", "o", "u"):
        consonants.append(char)
    else: vowels.append(char)

visited = set()

for vowels_count in range(2,min(L,len(vowels)+1)):
    consonants_count = L - vowels_count
    
    for temp_vowel in combinations(vowels, vowels_count):
        for temp_consonant in combinations(consonants, consonants_count):
            
            answer = []
            answer.extend(temp_vowel)
            answer.extend(temp_consonant)
            answer.sort()
            visited.add("".join(answer))
            
for ans in sorted(list(visited)):
    print(ans)

@alstjr7437 alstjr7437 removed their request for review July 12, 2024 09:09
@SeongHoonC SeongHoonC merged commit 77123fe into main Jul 14, 2024
6 checks passed
@SeongHoonC SeongHoonC deleted the 30-SeongHoonC branch July 14, 2024 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants