Submission #937731
Source Code Expand
import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; import java.util.function.BiFunction; import java.util.function.Function; public class Main { void run() { int[] cnt = new int[256]; for (char c : sc.next().toCharArray()) { ++cnt[c]; } int one = 0; int guu = 0; for (int i = 'a'; i <= 'z'; ++i) { if (cnt[i] % 2 == 1) { ++one; --cnt[i]; } guu += cnt[i]; } if (one == 0) { System.out.println(guu); } else { int want = (guu / one) / 2; System.out.println(1 + want * 2); } } Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main().run(); } int ni() { return Integer.parseInt(sc.next()); } void debug(Object... os) { System.err.println(Arrays.deepToString(os)); } class BIT<T> { int n; ArrayList<T> bit; BiFunction<T, T, T> bif; BIT(int n, BiFunction<T, T, T> bif, T defaultValue) { this.n = n; bit = new ArrayList<>(n + 1); for (int i = 0; i < n + 1; ++i) { bit.add(defaultValue); } this.bif = bif; } void update(int i, T v) { for (int x = i; x <= n; x += x & -x) { bit.set(x, bif.apply(bit.get(x), v)); } } T reduce(int i, T defaultValue) { T ret = defaultValue; for (int x = i; x > 0; x -= x & -x) { ret = bif.apply(ret, bit.get(x)); } return ret; } } long MOD = 1_000_000_007; long pow(long a, long r) { long sum = 1; while (r > 0) { if ((r & 1) == 1) { sum *= a; sum %= MOD; } a *= a; a %= MOD; r >>= 1; } return sum; } long C(int n, int r) { long sum = 1; for (int i = n; 0 < i; --i) { sum *= i; sum %= MOD; } long s = 1; for (int i = r; 0 < i; --i) { s *= i; s %= MOD; } sum *= pow(s, MOD - 2); sum %= MOD; long t = 1; for (int i = n - r; 0 < i; --i) { t *= i; t %= MOD; } sum *= pow(t, MOD - 2); sum %= MOD; return sum; } double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0; /** * 黄金分割探索 * * @param left 下限 * @param right 上限 * @param f 探索する関数 * @param comp 上に凸な関数を探索するときは、Comparator.comparingDouble(Double::doubleValue) * 下に凸な関数を探索するときは、Comparator.comparingDouble(Double::doubleValue).reversed() * @return 極値の座標x */ double goldenSectionSearch(double left, double right, Function<Double, Double> f, Comparator<Double> comp) { double c1 = divideInternally(left, right, 1, GOLDEN_RATIO); double c2 = divideInternally(left, right, GOLDEN_RATIO, 1); double d1 = f.apply(c1); double d2 = f.apply(c2); while (right - left > 1e-9) { if (comp.compare(d1, d2) > 0) { right = c2; c2 = c1; d2 = d1; c1 = divideInternally(left, right, 1, GOLDEN_RATIO); d1 = f.apply(c1); } else { left = c1; c1 = c2; d1 = d2; c2 = divideInternally(left, right, GOLDEN_RATIO, 1); d2 = f.apply(c2); } } return right; } /** * [a,b]をm:nに内分する点を返す */ double divideInternally(double a, double b, double m, double n) { return (n * a + m * b) / (m + n); } }
Submission Info
Submission Time | |
---|---|
Task | B - 回文分割 |
User | arukuka |
Language | Java8 (OpenJDK 1.8.0) |
Score | 100 |
Code Size | 3624 Byte |
Status | AC |
Exec Time | 179 ms |
Memory | 13564 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 123 ms | 9548 KB |
0_01.txt | AC | 123 ms | 9544 KB |
0_02.txt | AC | 126 ms | 9680 KB |
0_03.txt | AC | 121 ms | 9556 KB |
1_00.txt | AC | 124 ms | 9552 KB |
1_01.txt | AC | 125 ms | 9552 KB |
1_02.txt | AC | 122 ms | 9544 KB |
1_03.txt | AC | 123 ms | 9548 KB |
1_04.txt | AC | 178 ms | 13564 KB |
1_05.txt | AC | 173 ms | 12744 KB |
1_06.txt | AC | 172 ms | 12628 KB |
1_07.txt | AC | 179 ms | 13192 KB |
1_08.txt | AC | 123 ms | 9552 KB |
1_09.txt | AC | 123 ms | 9552 KB |
1_10.txt | AC | 121 ms | 9556 KB |
1_11.txt | AC | 125 ms | 9556 KB |
1_12.txt | AC | 123 ms | 9680 KB |
1_13.txt | AC | 122 ms | 9672 KB |
1_14.txt | AC | 123 ms | 9548 KB |
1_15.txt | AC | 123 ms | 9548 KB |
1_16.txt | AC | 123 ms | 9552 KB |
1_17.txt | AC | 126 ms | 9552 KB |
1_18.txt | AC | 124 ms | 9548 KB |
1_19.txt | AC | 123 ms | 9680 KB |
1_20.txt | AC | 124 ms | 9544 KB |
1_21.txt | AC | 123 ms | 9548 KB |
1_22.txt | AC | 122 ms | 9552 KB |
1_23.txt | AC | 138 ms | 9552 KB |
1_24.txt | AC | 123 ms | 9676 KB |
1_25.txt | AC | 160 ms | 10572 KB |
1_26.txt | AC | 147 ms | 9936 KB |
1_27.txt | AC | 156 ms | 10448 KB |
1_28.txt | AC | 152 ms | 10056 KB |
1_29.txt | AC | 179 ms | 13408 KB |
1_30.txt | AC | 149 ms | 10444 KB |
1_31.txt | AC | 178 ms | 13436 KB |
1_32.txt | AC | 160 ms | 10576 KB |
1_33.txt | AC | 147 ms | 9932 KB |
1_34.txt | AC | 153 ms | 10184 KB |
1_35.txt | AC | 153 ms | 10184 KB |
1_36.txt | AC | 157 ms | 10444 KB |
1_37.txt | AC | 148 ms | 10448 KB |
1_38.txt | AC | 161 ms | 12880 KB |
1_39.txt | AC | 179 ms | 13380 KB |
1_40.txt | AC | 146 ms | 9932 KB |