Submission #4595975
Source Code Expand
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; public class Main { void submit() { nextInt(); String s = nextToken(); int[] a = new int[26]; for (char c : s.toCharArray()) { a[c - 'a']++; } int ret = 1; for (int x : a) { ret = (int)((long)ret * (x + 1) % P); } ret--; if (ret < 0) { ret += P; } out.println(ret); } static final int P = 1_000_000_007; void test() { } void stress() { for (int tst = 0;; tst++) { if (false) { throw new AssertionError(); } System.err.println(tst); } } Main() throws IOException { is = System.in; out = new PrintWriter(System.out); submit(); // stress(); // test(); out.close(); } static final Random rng = new Random(); static final int C = 5; static int rand(int l, int r) { return l + rng.nextInt(r - l + 1); } public static void main(String[] args) throws IOException { new Main(); } private InputStream is; PrintWriter out; private byte[] buf = new byte[1 << 14]; private int bufSz = 0, bufPtr = 0; private int readByte() { if (bufSz == -1) throw new RuntimeException("Reading past EOF"); if (bufPtr >= bufSz) { bufPtr = 0; try { bufSz = is.read(buf); } catch (IOException e) { throw new RuntimeException(e); } if (bufSz <= 0) return -1; } return buf[bufPtr++]; } private boolean isTrash(int c) { return c < 33 || c > 126; } private int skip() { int b; while ((b = readByte()) != -1 && isTrash(b)) ; return b; } String nextToken() { int b = skip(); StringBuilder sb = new StringBuilder(); while (!isTrash(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } String nextString() { int b = readByte(); StringBuilder sb = new StringBuilder(); while (!isTrash(b) || b == ' ') { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } double nextDouble() { return Double.parseDouble(nextToken()); } char nextChar() { return (char) skip(); } int nextInt() { int ret = 0; int b = skip(); if (b != '-' && (b < '0' || b > '9')) { throw new InputMismatchException(); } boolean neg = false; if (b == '-') { neg = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { ret = ret * 10 + (b - '0'); } else { if (b != -1 && !isTrash(b)) { throw new InputMismatchException(); } return neg ? -ret : ret; } b = readByte(); } } long nextLong() { long ret = 0; int b = skip(); if (b != '-' && (b < '0' || b > '9')) { throw new InputMismatchException(); } boolean neg = false; if (b == '-') { neg = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { ret = ret * 10 + (b - '0'); } else { if (b != -1 && !isTrash(b)) { throw new InputMismatchException(); } return neg ? -ret : ret; } b = readByte(); } } }
Submission Info
Submission Time | |
---|---|
Task | A - Colorful Subsequence |
User | mmaxio |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 3118 Byte |
Status | AC |
Exec Time | 86 ms |
Memory | 21588 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt, sample-03.txt |
All | 01-00.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-00.txt | AC | 85 ms | 21588 KiB |
01-01.txt | AC | 83 ms | 19664 KiB |
01-02.txt | AC | 86 ms | 19156 KiB |
01-03.txt | AC | 67 ms | 20692 KiB |
01-04.txt | AC | 68 ms | 18900 KiB |
01-05.txt | AC | 67 ms | 20564 KiB |
01-06.txt | AC | 85 ms | 20052 KiB |
01-07.txt | AC | 83 ms | 21332 KiB |
01-08.txt | AC | 82 ms | 20308 KiB |
01-09.txt | AC | 83 ms | 20436 KiB |
sample-01.txt | AC | 67 ms | 19028 KiB |
sample-02.txt | AC | 68 ms | 21204 KiB |
sample-03.txt | AC | 68 ms | 20820 KiB |