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

[P2] 9275 패션왕 신해빈 #128

Merged
merged 1 commit into from
Dec 8, 2024
Merged

[P2] 9275 패션왕 신해빈 #128

merged 1 commit into from
Dec 8, 2024

Conversation

wwan13
Copy link
Owner

@wwan13 wwan13 commented Dec 8, 2024

Problem Info

Code

package boj9375;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
        int t = Integer.parseInt(readLine());
        while (t-- > 0) {
            int n = Integer.parseInt(readLine());
            HashMap<String, Integer> clothes = new HashMap<>();

            for (int i = 0; i < n; i++) {
                String[] input = readLine().split(" ");
                String type = input[1];
                clothes.put(type, clothes.getOrDefault(type, 0) + 1);
            }

            int combinations = 1;
            for (int count : clothes.values()) {
                combinations *= (count + 1);
            }

            System.out.println(combinations - 1);
        }
    }

    private static String readLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Note

@github-actions github-actions bot added data_structures 알고리즘: data_structures disjoint_set 알고리즘: disjoint_set graphs 알고리즘: graphs labels Dec 8, 2024
@github-actions github-actions bot changed the title solve : 9275 패션왕 신해빈 [P2] 9275 패션왕 신해빈 Dec 8, 2024
@wwan13 wwan13 merged commit 80b60b0 into main Dec 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data_structures 알고리즘: data_structures disjoint_set 알고리즘: disjoint_set graphs 알고리즘: graphs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant