結果
問題 | No.2671 NUPC Decompressor |
ユーザー | Asahi |
提出日時 | 2024-03-15 23:11:28 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 118 ms / 2,000 ms |
コード長 | 8,652 bytes |
コンパイル時間 | 2,440 ms |
コンパイル使用メモリ | 86,216 KB |
実行使用メモリ | 41,572 KB |
最終ジャッジ日時 | 2024-09-30 02:45:00 |
合計ジャッジ時間 | 5,123 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 108 ms
40,144 KB |
testcase_01 | AC | 114 ms
41,472 KB |
testcase_02 | AC | 105 ms
41,504 KB |
testcase_03 | AC | 98 ms
41,420 KB |
testcase_04 | AC | 107 ms
40,008 KB |
testcase_05 | AC | 118 ms
40,916 KB |
testcase_06 | AC | 110 ms
40,824 KB |
testcase_07 | AC | 115 ms
41,248 KB |
testcase_08 | AC | 110 ms
41,572 KB |
testcase_09 | AC | 108 ms
41,160 KB |
testcase_10 | AC | 116 ms
40,184 KB |
testcase_11 | AC | 108 ms
41,300 KB |
testcase_12 | AC | 109 ms
41,028 KB |
testcase_13 | AC | 113 ms
41,388 KB |
testcase_14 | AC | 107 ms
40,216 KB |
testcase_15 | AC | 108 ms
41,488 KB |
ソースコード
import java.util.*; import java.io.*; import java.math.*; import java.util.stream.*; import java.util.function.*; class Main implements Runnable { boolean DEBUG = true ; public void solve() { int k = in.nextInt(); char [] nupc = {'N','U','P','C'}; TreeSet<String> set = new TreeSet<>(); for(int i = 0 ; i < (1 << 4) ; i ++) { StringBuilder sb = new StringBuilder(); for(int j = 0 ; j < 4 ; j ++) { sb.append(nupc[j]); if(((i >> j) & 1) == 1) sb.append(sb.toString()); } set.add(sb.toString()); } int ans = 0 ; for(String v : set) if(++ans == k) { out.println(v); return; } } public PrintWriter out = new PrintWriter(System.out); public Input in = new Input(); public static final int inf = (1 << 30); public static final long lnf = (1L << 60); public static final String yes = "Yes" , no = "No" ; public static final String YES = "YES" , NO = "NO" ; public static final int mod7 = 1000000007 , mod9 = 998244353 ; 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 static void main(String [] args) { new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start(); } public void run() { solve(); out.flush(); } public void fill (int [] array , int e) { Arrays.fill(array , e) ; } public void fill (long [] array , long e) { Arrays.fill(array , e) ; } public void fill (int [][] array , int e) { for(int i = 0 ; i < array.length ; i ++) fill(array[i] , e) ; } public void fill (long [][] array , long e) { for(int i = 0 ; i < array.length ; i ++) fill(array[i] , e) ; } public int [] sort(int [] array) { int [] p = new int [array.length]; Arrays.sort(p); return p ; } public long [] sort(long [] array) { long [] p = new long [array.length]; Arrays.sort(p); return p ; } public String [] sort(String [] array) { String [] p = new String[array.length]; Arrays.sort(p); return p ; } public int min(int ... array) { int min = inf ; for(int v : array) min = Math.min(min , v) ; return min ; } public long min(long ... array) { long min = lnf ; for(long v : array) min = Math.min(min , v) ; return min ; } public int max(int ... array) { int max = -inf ; for(int v : array) max = Math.max(max , v) ; return max ; } public long max(long ... array) { long max = -lnf ; for(long v : array) max = Math.max(max , v) ; return max ; } public int sum(int ... array) { int sum = 0 ; for(int v : array) sum += v ; return sum ; } public long sum(long ... array) { long sum = 0 ; for(long v : array) sum += v ; return sum ; } public String toString(int a) { return Integer.toString(a); } public String toString(long a) { return Long.toString(a); } public int parseInt (String a) { return Integer.parseInt(a) ; } public long parseLong(String a) { return Long.parseLong(a) ; } public int [] random(int n , int lower , int upper) { return new Random().ints (n , lower , upper).toArray() ; } public long [] random(int n , long lower , long upper) { return new Random().longs(n , lower , upper).toArray() ; } public void DEBUG(int [] a) { System.out.println(Arrays.toString(a)) ; } public void DEBUG(long [] a) { System.out.println(Arrays.toString(a)) ; } public void DEBUG(String [] a) { System.out.println(Arrays.toString(a)) ; } public void DEBUG(char [] a) { System.out.println(Arrays.toString(a)) ; } public void DEBUG(double [] a) { System.out.println(Arrays.toString(a)) ; } public void DEBUG(boolean[] a) { System.out.println(Arrays.toString(a)) ; } public void DEBUG(int [][] a) { for(int i = 0 ; i < a.length ; i ++ ) System.out.println(Arrays.toString(a[i])) ; } public void DEBUG(long [][] a) { for(int i = 0 ; i < a.length ; i ++ ) System.out.println(Arrays.toString(a[i])) ; } public void DEBUG(String [][] a) { for(int i = 0 ; i < a.length ; i ++ ) System.out.println(Arrays.toString(a[i])) ; } public void DEBUG(char [][] a) { for(int i = 0 ; i < a.length ; i ++ ) System.out.println(Arrays.toString(a[i])) ; } public void DEBUG(double [][] a) { for(int i = 0 ; i < a.length ; i ++ ) System.out.println(Arrays.toString(a[i])) ; } public void DEBUG(boolean[][] a) { for(int i = 0 ; i < a.length ; i ++ ) System.out.println(Arrays.toString(a[i])) ; } } class Input { 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 ; } }