From b9bb43e5de91b07eee2898a85b44c0c80974a678 Mon Sep 17 00:00:00 2001 From: oncsr Date: Wed, 12 Feb 2025 12:31:17 +0900 Subject: [PATCH] =?UTF-8?q?[20250212]=20BOJ=20/=20G3=20/=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=83=90=EC=83=89=EA=B8=B0=20/=20=EA=B6=8C?= =?UTF-8?q?=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4 \355\203\220\354\203\211\352\270\260.md" | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 "khj20006/202502/12 BOJ G3 \355\214\214\354\235\274 \355\203\220\354\203\211\352\270\260.md" diff --git "a/khj20006/202502/12 BOJ G3 \355\214\214\354\235\274 \355\203\220\354\203\211\352\270\260.md" "b/khj20006/202502/12 BOJ G3 \355\214\214\354\235\274 \355\203\220\354\203\211\352\270\260.md" new file mode 100644 index 00000000..822b3ee3 --- /dev/null +++ "b/khj20006/202502/12 BOJ G3 \355\214\214\354\235\274 \355\203\220\354\203\211\352\270\260.md" @@ -0,0 +1,119 @@ +```java + +import java.util.*; +import java.io.*; +import java.math.BigInteger; + +class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + static long nextLong() {return Long.parseLong(st.nextToken());} + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + static List[] arr; + static int N; + static HashMap hash; + static List temp; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + } + + static void ready() throws Exception{ + + N = Integer.parseInt(br.readLine()); + arr = new List[N]; + temp = new ArrayList<>(); + for(int i=0;i(); + String number = ""; + for(char c:br.readLine().toCharArray()) { + if(('A'<=c && c<='Z') || ('a'<=c && c<='z')) { + if(!number.equals("")) { + arr[i].add(number); + temp.add(number); + } + arr[i].add(""+c); + number = ""; + } + else { + number += c; + } + } + if(!number.equals("")) { + arr[i].add(number); + temp.add(number); + } + + } + + hash = new HashMap<>(); + + Collections.sort(temp, (p,q) -> { + BigInteger a = new BigInteger(p); + BigInteger b = new BigInteger(q); + if(a.compareTo(b) == 1) return 1; + if(a.compareTo(b) == -1) return -1; + int a_zeros = 0, b_zeros = 0; + for(char c:p.toCharArray()) { + if(c != '0') break; + a_zeros++; + } + for(char c:q.toCharArray()) { + if(c != '0') break; + b_zeros++; + } + return a_zeros-b_zeros; + }); + + int num = 1; + String prev = "a"; + for(String i : temp) { + if(i == prev) continue; + hash.put(i, num++); + prev = i; + } + bw.flush(); + + for(int i=0;i<26;i++) { + hash.put(""+(char)(i+65), num++); + hash.put(""+(char)(i+97), num++); + } + + + } + + static void solve() throws Exception{ + + Arrays.sort(arr,(a,b) -> { + + for(int i=0;i 0) return 1; + } + return a.size()-b.size(); + + }); + + for(List L:arr) { + for(String i:L) bw.write(i); + bw.write("\n"); + } + + } + +} + +```