結果
問題 | No.2671 NUPC Decompressor |
ユーザー | はまお |
提出日時 | 2024-03-15 21:36:14 |
言語 | Go (1.22.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 3,578 bytes |
コンパイル時間 | 13,805 ms |
コンパイル使用メモリ | 234,572 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-30 00:30:54 |
合計ジャッジ時間 | 10,423 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,820 KB |
testcase_02 | AC | 1 ms
6,820 KB |
testcase_03 | AC | 1 ms
6,816 KB |
testcase_04 | AC | 1 ms
6,820 KB |
testcase_05 | AC | 1 ms
6,820 KB |
testcase_06 | AC | 1 ms
6,816 KB |
testcase_07 | AC | 1 ms
6,816 KB |
testcase_08 | AC | 1 ms
6,820 KB |
testcase_09 | AC | 1 ms
6,816 KB |
testcase_10 | AC | 1 ms
6,816 KB |
testcase_11 | AC | 1 ms
6,820 KB |
testcase_12 | AC | 1 ms
6,820 KB |
testcase_13 | AC | 1 ms
6,816 KB |
testcase_14 | AC | 2 ms
6,816 KB |
testcase_15 | AC | 1 ms
6,820 KB |
ソースコード
package main import ( "bufio" "fmt" "os" "sort" "strconv" "strings" ) func main() { k := readInt() S := make([]string, 16) T := make([]string, 16) nupc := []string{"N", "U", "P", "C"} for b := 0; b < (1 << 4); b++ { s := "" for i := 0; i < 4; i++ { s += nupc[i] if (b>>i)&1 == 1 { s += "1" } else { s += "2" } } S[b] = s } for i := 0; i < 16; i++ { s := S[i] t := "" for j := 0; j < 4; j++ { t += nupc[j] if s[2*j+1] == '2' { t += t } } T[i] = t } sort.Slice(T, func(i, j int) bool { return T[i] < T[j] }) writeLine(T[k-1]) } func sum[T int | float64](arr ...T) T { sum := arr[0] for i := 1; i < len(arr); i++ { sum += arr[i] } return sum } func pow(x, n int) int { res := 1 for n > 0 { if n&1 == 1 { res = res * x } x = x * x n >>= 1 } return res } func lcm(a, b int) int { return a / gcd(a, b) * b } func gcd(a, b int) int { if b == 0 { return a } return gcd(b, a%b) } func abs[T int | float64](x T) T { if x < 0 { return -x } return x } func min[T int | float64](arr ...T) T { min := arr[0] for _, v := range arr { if v < min { min = v } } return min } func max[T int | float64](arr ...T) T { max := arr[0] for _, v := range arr { if v > max { max = v } } return max } var _stdInReader = bufio.NewReader(os.Stdin) func readLine() string { line, _ := _stdInReader.ReadString('\n') return strings.TrimSpace(line) } func readString() string { return readLine() } func readInt() int { strs := readString() num, _ := strconv.Atoi(strs) return num } func readLong() int64 { strs := readString() num, _ := strconv.ParseInt(strs, 10, 64) return num } func readStrings() []string { line := readLine() return strings.Split(line, " ") } func readInts() []int { strs := readStrings() arr := make([]int, len(strs)) for i := 0; i < len(strs); i++ { arr[i], _ = strconv.Atoi(strs[i]) } return arr } func readLongs() []int64 { strs := readStrings() arr := make([]int64, len(strs)) for i := 0; i < len(strs); i++ { arr[i], _ = strconv.ParseInt(strs[i], 10, 64) } return arr } func readDoubles() []float64 { strs := readStrings() arr := make([]float64, len(strs)) for i := 0; i < len(strs); i++ { arr[i], _ = strconv.ParseFloat(strs[i], 64) } return arr } func scanStringVariables(args ...*string) { n := len(args) scanned := 0 for n > scanned { inputSlice := readStrings() m := len(inputSlice) if m == 0 || m > n-scanned { fmt.Print("Something wrong in scanStringVariables !!!") return } for i := 0; i < m; i++ { *args[i+scanned] = inputSlice[i] } scanned += m } } func scanIntVariables(args ...*int) { n := len(args) scanned := 0 for n > scanned { inputSlice := readInts() m := len(inputSlice) if m == 0 || m > n-scanned { fmt.Printf("m %d n %d scanned %d. ", m, n, scanned) fmt.Print("Something wrong in scanIntVariables !!!") return } for i := 0; i < m; i++ { *args[i+scanned] = inputSlice[i] } scanned += m } } func scanLongVariables(args ...*int64) { n := len(args) scanned := 0 for n > scanned { inputSlice := readLongs() m := len(inputSlice) if m == 0 || m > n-scanned { fmt.Print("Something wrong in scanIntVariables !!!") return } for i := 0; i < m; i++ { *args[i+scanned] = inputSlice[i] } scanned += m } } func write(arg ...interface{}) { fmt.Print(arg...) } func writeLine(arg ...interface{}) { fmt.Println(arg...) } func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }