結果
| 問題 | No.1171 Runs in Subsequences |
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-01-22 12:42:54 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,356 bytes |
| 記録 | |
| コンパイル時間 | 2,655 ms |
| コンパイル使用メモリ | 84,580 KB |
| 実行使用メモリ | 210,264 KB |
| 最終ジャッジ日時 | 2026-06-01 07:23:27 |
| 合計ジャッジ時間 | 10,322 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 6 WA * 5 TLE * 1 -- * 6 |
ソースコード
import java.util.*;
public class Main {
static final int MOD = 1000000007;
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
ArrayList<HashMap<Integer, Integer>> counts = new ArrayList<>();
HashMap<Integer, Integer> total = new HashMap<>();
for (int i = 0; i < 26; i++) {
counts.add(new HashMap<>());
}
for (char c : sc.next().toCharArray()) {
int idx = c - 'a';
for (int x : counts.get(idx).keySet()) {
total.put(x, (total.get(x) - counts.get(idx).get(x) + MOD) % MOD);
counts.get(idx).put(x, counts.get(idx).get(x) * 2 % MOD);
}
counts.get(idx).put(1, counts.get(idx).getOrDefault(1, 0) + 1);
for (int x : total.keySet()) {
counts.get(idx).put(x + 1, (counts.get(idx).getOrDefault(x + 1, 0) + total.get(x)) % MOD);
}
for (int x : counts.get(idx).keySet()) {
total.put(x, total.getOrDefault(x, 0) + counts.get(idx).get(x));
}
}
long ans = 0;
for (Map.Entry<Integer, Integer> entry : total.entrySet()) {
ans += (long)(entry.getKey().intValue()) * entry.getValue() % MOD;
ans %= MOD;
}
System.out.println(ans);
}
}
tenten