結果
問題 | No.2715 Unique Chimatagram |
ユーザー | Asahi |
提出日時 | 2024-04-05 22:05:04 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 10,515 bytes |
コンパイル時間 | 4,205 ms |
コンパイル使用メモリ | 97,212 KB |
実行使用メモリ | 58,328 KB |
最終ジャッジ日時 | 2024-04-05 22:05:20 |
合計ジャッジ時間 | 13,579 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 133 ms
57,604 KB |
testcase_01 | AC | 140 ms
57,676 KB |
testcase_02 | AC | 136 ms
57,684 KB |
testcase_03 | AC | 123 ms
56,684 KB |
testcase_04 | AC | 135 ms
57,680 KB |
testcase_05 | AC | 131 ms
57,592 KB |
testcase_06 | AC | 131 ms
57,716 KB |
testcase_07 | AC | 135 ms
57,560 KB |
testcase_08 | AC | 157 ms
57,320 KB |
testcase_09 | AC | 158 ms
57,328 KB |
testcase_10 | AC | 165 ms
58,208 KB |
testcase_11 | AC | 174 ms
58,188 KB |
testcase_12 | AC | 158 ms
57,344 KB |
testcase_13 | WA | - |
testcase_14 | AC | 165 ms
58,196 KB |
testcase_15 | AC | 161 ms
57,312 KB |
testcase_16 | AC | 169 ms
58,192 KB |
testcase_17 | AC | 198 ms
58,196 KB |
testcase_18 | AC | 166 ms
57,468 KB |
testcase_19 | AC | 185 ms
58,112 KB |
testcase_20 | AC | 189 ms
58,116 KB |
testcase_21 | AC | 184 ms
58,328 KB |
testcase_22 | AC | 183 ms
58,092 KB |
testcase_23 | AC | 202 ms
57,468 KB |
testcase_24 | AC | 170 ms
57,724 KB |
testcase_25 | AC | 187 ms
58,324 KB |
testcase_26 | AC | 185 ms
58,244 KB |
testcase_27 | AC | 167 ms
57,460 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 161 ms
58,080 KB |
testcase_31 | WA | - |
testcase_32 | AC | 153 ms
57,604 KB |
testcase_33 | AC | 133 ms
57,596 KB |
testcase_34 | AC | 162 ms
57,552 KB |
testcase_35 | AC | 135 ms
57,812 KB |
testcase_36 | AC | 129 ms
57,548 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 166 ms
58,112 KB |
testcase_42 | AC | 139 ms
56,832 KB |
ソースコード
import java.util.*; import java.io.*; import java.math.*; import java.util.stream.*; import java.util.function.*; class Main { public final PrintWriter out = new PrintWriter(System.out); public final FastScanner in = new FastScanner(); public static final int inf = (1 << 30) ; public static final long lnf = (1L << 30); public boolean dbg = false ; public void solve() { int n = in.nextInt(); String [] str = new String[n]; Map<String,Integer> cnt = new HashMap<>(); for(int i = 0 ; i < n ; i ++) { str[i] = in.next(); cnt.put(str[i] , cnt.getOrDefault(str[i] , 0) + 1); } for(char c = 'a' ; c <= 'z' ; c ++) { Map<String,Integer> cnt2 = new HashMap<>(); Map<String,Integer> cnt3 = new HashMap<>(); for(String sss : cnt.keySet()) { if(cnt.get(sss) >= 2) continue; String sb = new StringBuilder(sss).append(c).toString(); cnt2.put(sb , cnt2.getOrDefault(sb , 0) + 1); } for(String sss : cnt2.keySet()) { if(cnt2.get(sss) >= 2) continue; List<Character> sorted = new ArrayList<>(); for(int j = 0 ; j < sss.length() ; j ++) sorted.add(sss.charAt(j)); Collections.sort(sorted); StringBuilder sb = new StringBuilder(); for(char cc : sorted) sb.append(cc); String res = sb.toString(); cnt3.put(res , cnt3.getOrDefault(res , 0) + 1); } for(String rr : cnt3.keySet()) { if(cnt3.get(rr) >= 2) continue; out.println(rr); out.flush(); return; } } out.println(-1); out.flush(); } public static void main(String [] args) { new Main().solve(); } } final class Utils { public static final int [] dy4 = {-1, 0, 1, 0} , dx4 = {0, 1, 0, -1} ; public static final int [] dy8 = {-1, -1, -1, 0, 1, 1, 1, 0} , dx8 = {-1, 0, 1, 1, 1, 0, -1, -1} ; public boolean isNumber(char c) { return '0' <= c && c <= '9'; } public boolean isNumber(String s) { for(int i = 0 ; i < s.length() ; i ++) if(!isNumber(s.charAt(i))) return false; return true ; } public boolean isInclude(int l , int r , int L , int R) { return (L <= l && r <= R) ; } public boolean isInclude_2D(int y , int x , int h , int w) { return (0 <= y && y < h) && (0 <= x && x < w); } public char Character_shift(char c , int s) { if('a' <= c && c <= 'z') return (char) (((((c - 'a') + s) % 26) + 26) % 26 + 'a'); if('A' <= c && c <= 'Z') return (char) (((((c - 'A') + s) % 26) + 26) % 26 + 'A'); if('0' <= c && c <= '9') return (char) (((((c - '0') + s) % 10) + 10) % 10 + '0'); return 'c'; } // ボクシング用 public Integer [] toInteger(int [] a) { return Arrays.stream(a).boxed().toArray(Integer[]::new); } public Long [] toLong(long [] a) { return Arrays.stream(a).boxed().toArray(Long[]::new); } public Double [] toDouble(double [] a) { return Arrays.stream(a).boxed().toArray(Double[]::new); } public <T> List<T> ArrayList(T [] a) { return Arrays.stream(a).collect(Collectors.toCollection(ArrayList::new)); } public <T> HashSet<T> HashSet(T [] a) { return Arrays.stream(a).collect(Collectors.toCollection(HashSet::new)); } public <T> TreeSet<T> TreeSet(T [] a) { return Arrays.stream(a).collect(Collectors.toCollection(TreeSet::new)); } public <T> Deque<T> Deque(T [] a) { return Arrays.stream(a).collect(Collectors.toCollection(ArrayDeque::new)); } public <T> PriorityQueue<T> PriorityQueue(T [] a) { return Arrays.stream(a).collect(Collectors.toCollection(PriorityQueue::new)); } // コレクション配列 public <T> List <T> [] ArrayList(int n) { @SuppressWarnings("unchecked") List<T> [] G = new ArrayList[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new ArrayList<>(); return G ; } public <T> HashSet <T> [] HashSet(int n) { @SuppressWarnings("unchecked") HashSet<T> [] G = new HashSet[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new HashSet<>() ; return G ; } public <T> TreeSet <T> [] TreeSet(int n) { @SuppressWarnings("unchecked") TreeSet<T> [] G = new TreeSet[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new TreeSet<>() ; return G ; } public <T> TreeSet <T> [] TreeSet(int n , Comparator<? super T> comparator) { @SuppressWarnings("unchecked") TreeSet<T> [] G = new TreeSet[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new TreeSet<>(comparator) ; return G ; } public <T> Deque <T> [] Deque(int n) { @SuppressWarnings("unchecked") Deque<T> [] G = new ArrayDeque[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new ArrayDeque<>(); return G ; } public <T> PriorityQueue <T> [] PriorityQueue(int n) { @SuppressWarnings("unchecked") PriorityQueue<T> [] G = new PriorityQueue[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new PriorityQueue<>(); return G ; } public <T> PriorityQueue <T> [] PriorityQueue(int n , Comparator<? super T> comparator) { @SuppressWarnings("unchecked") PriorityQueue<T> [] G = new PriorityQueue[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new PriorityQueue<>(comparator); return G ; } public <K,V> HashMap <K,V> [] HashMap(int n) { @SuppressWarnings("unchecked") HashMap<K,V> [] G = new HashMap[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new HashMap<>() ; return G ; } public <K,V> TreeMap <K,V> [] TreeMap(int n) { @SuppressWarnings("unchecked") TreeMap<K,V> [] G = new TreeMap[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new TreeMap<>() ; return G ; } public <K,V> TreeMap <K,V> [] TreeMap(int n , Comparator<? super K> comparator) { @SuppressWarnings("unchecked") TreeMap<K,V> [] G = new TreeMap[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new TreeMap<>(comparator) ; return G ; } } final class FastScanner { private final InputStream in = System.in; private final Scanner sc = new Scanner(System.in); private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) { ptr++; } return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next()); } public char nextChar() { return next().charAt(0); } public BigInteger nextBigInteger() { return sc.nextBigInteger(); } public int [] nextInt(int n) { int [] array = new int[n]; for(int i = 0 ; i < n ; i ++) { array[i] = nextInt(); } return array ; } public int [][] nextInt(int n , int m) { int [][] array = new int[n][m]; for(int i = 0 ; i < n ; i ++) { array[i] = nextInt(m); } return array ; } public long [] nextLong(int n) { long [] array = new long[n]; for(int i = 0 ; i < n ; i ++) { array[i] = nextLong(); } return array ; } public long [][] nextLong(int n , int m) { long [][] array = new long[n][m]; for(int i = 0 ; i < n ; i ++) { array[i] = nextLong(m); } return array ; } public double [] nextDouble(int n) { double [] array = new double[n]; for(int i = 0 ; i < n ; i ++) { array[i] = nextDouble(); } return array ; } public String [] next(int n) { String [] array = new String[n]; for(int i = 0 ; i < n ; i ++) { array[i] = next(); } return array ; } public String [][] next(int n , int m) { String [][] array = new String[n][m]; for(int i = 0 ; i < n ; i ++) { array[i] = next(m); } return array ; } public char [] nextChar(int n) { return next().toCharArray(); } public char [][] nextChar(int n , int m) { char [][] array = new char[n][m]; for(int i = 0 ; i < n ; i ++) { array[i] = nextChar(m); } return array ; } }