結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー | ぬるぬる |
提出日時 | 2016-05-15 01:06:32 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 826 bytes |
コンパイル時間 | 3,141 ms |
コンパイル使用メモリ | 74,236 KB |
実行使用メモリ | 52,004 KB |
最終ジャッジ日時 | 2024-04-15 21:39:35 |
合計ジャッジ時間 | 16,057 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
42,944 KB |
testcase_01 | AC | 52 ms
37,288 KB |
testcase_02 | AC | 51 ms
37,040 KB |
testcase_03 | AC | 52 ms
37,576 KB |
testcase_04 | AC | 55 ms
37,492 KB |
testcase_05 | AC | 52 ms
37,056 KB |
testcase_06 | AC | 54 ms
37,528 KB |
testcase_07 | AC | 54 ms
37,260 KB |
testcase_08 | AC | 55 ms
37,372 KB |
testcase_09 | AC | 57 ms
37,496 KB |
testcase_10 | WA | - |
testcase_11 | AC | 264 ms
45,088 KB |
testcase_12 | WA | - |
testcase_13 | AC | 247 ms
45,236 KB |
testcase_14 | AC | 82 ms
39,180 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | AC | 63 ms
50,304 KB |
testcase_24 | AC | 65 ms
50,696 KB |
testcase_25 | AC | 63 ms
50,352 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Test346 { public static void main(String[] args) { int result = 0; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { String str = br.readLine(); char[] ch = str.toCharArray(); Pattern pattern = Pattern.compile("c"); for(int i=0;i<ch.length;i++){ String s = String.valueOf(ch[i]); Matcher matcher = pattern.matcher(s); if(matcher.matches()){ int count=0; for(int j=i+1;j<ch.length;j++){ if(ch[j]=='w'){ count++; } } result += count * (count - 1) / 2 ; } } System.out.println(result); } catch (IOException e) { e.printStackTrace(); } } }