結果
問題 | No.2073 Concon Substrings (Swap Version) |
ユーザー | 箱星 |
提出日時 | 2022-09-16 22:09:04 |
言語 | Kotlin (1.9.23) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,485 bytes |
コンパイル時間 | 14,290 ms |
コンパイル使用メモリ | 453,552 KB |
実行使用メモリ | 71,532 KB |
最終ジャッジ日時 | 2024-12-21 20:57:48 |
合計ジャッジ時間 | 34,104 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 286 ms
51,452 KB |
testcase_01 | AC | 275 ms
51,164 KB |
testcase_02 | AC | 281 ms
51,292 KB |
testcase_03 | AC | 277 ms
51,460 KB |
testcase_04 | AC | 285 ms
51,412 KB |
testcase_05 | AC | 514 ms
65,220 KB |
testcase_06 | AC | 530 ms
65,084 KB |
testcase_07 | AC | 273 ms
51,476 KB |
testcase_08 | AC | 519 ms
60,940 KB |
testcase_09 | AC | 521 ms
61,184 KB |
testcase_10 | AC | 548 ms
65,236 KB |
testcase_11 | AC | 526 ms
65,208 KB |
testcase_12 | AC | 290 ms
51,440 KB |
testcase_13 | AC | 340 ms
54,004 KB |
testcase_14 | AC | 516 ms
63,972 KB |
testcase_15 | AC | 525 ms
57,276 KB |
testcase_16 | AC | 529 ms
65,124 KB |
testcase_17 | AC | 276 ms
51,296 KB |
testcase_18 | AC | 333 ms
53,928 KB |
testcase_19 | AC | 511 ms
65,180 KB |
testcase_20 | AC | 534 ms
61,172 KB |
testcase_21 | AC | 508 ms
61,148 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 525 ms
61,048 KB |
testcase_31 | AC | 490 ms
57,252 KB |
testcase_32 | AC | 378 ms
54,528 KB |
testcase_33 | AC | 434 ms
55,908 KB |
testcase_34 | AC | 391 ms
54,600 KB |
testcase_35 | AC | 530 ms
59,340 KB |
testcase_36 | AC | 425 ms
55,936 KB |
testcase_37 | AC | 517 ms
58,920 KB |
testcase_38 | AC | 379 ms
54,612 KB |
testcase_39 | AC | 547 ms
61,236 KB |
testcase_40 | AC | 512 ms
58,852 KB |
testcase_41 | AC | 550 ms
61,232 KB |
ソースコード
import java.io.PrintWriter import java.util.* import kotlin.math.* fun PrintWriter.solve() { val n = nextInt() val s = nextLine() val s0 = (0 until n).map { s[3 * it] } val s1 = (0 until n).map { s[3 * it + 1] } val s2 = (0 until n).map { s[3 * it + 2] } val c0 = s0.count { it == 'c' } val c1 = s1.count { it == 'c' } val c2 = s2.count { it == 'c' } val o0 = s0.count { it == 'o' } val o1 = s1.count { it == 'o' } val o2 = s2.count { it == 'o' } val n0 = s0.count { it == 'n' } val n1 = s1.count { it == 'n' } val n2 = s2.count { it == 'n' } val x0 = n - c0 - o0 - n0 val x1 = n - c1 - o1 - n1 val x2 = n - c2 - o2 - n2 val con0 = minOf(c0, o1, n2) val con1 = minOf(c1, o2, n0) val con2 = minOf(c2, o0, n1) val con = con0 + con1 + con2 if (con0 > 0 && con1 > 0 && con2 > 0 && x0 == 0 && x1 == 0 && x2 == 0 && con == n) { println(con - 1) } else { println(con) } } class UnionFind(n: Int) { private val rank = IntArray(n) { 0 } private val parent = IntArray(n) { -1 } fun find(x: Int): Int { if (parent[x] < 0) { return x } parent[x] = find(parent[x]) return parent[x] } fun unite(x: Int, y: Int) { val x1 = find(x) val y1 = find(y) if (x1 == y1) { return } if (rank[x1] < rank[y1]) { parent[y1] += parent[x1] parent[x1] = y1 } else { parent[x1] += parent[y1] parent[y1] = x1 if (rank[x1] == rank[y1]) { rank[x1]++ } } } fun same(x: Int, y: Int): Boolean { return find(x) == find(y) } fun size(x: Int): Int { return -parent[find(x)] } } fun main() { Thread(null, { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() }, "solve", abs(1L.shl(26))) .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } } .apply { start() }.join() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() // endregion