結果
問題 | No.345 最小チワワ問題 |
ユーザー | TwinkleStar74 |
提出日時 | 2017-09-19 00:43:02 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 830 bytes |
コンパイル時間 | 2,306 ms |
コンパイル使用メモリ | 74,764 KB |
実行使用メモリ | 50,612 KB |
最終ジャッジ日時 | 2024-04-25 15:37:22 |
合計ジャッジ時間 | 4,724 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
50,320 KB |
testcase_01 | AC | 49 ms
50,188 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 50 ms
50,476 KB |
testcase_05 | AC | 50 ms
49,944 KB |
testcase_06 | AC | 52 ms
50,320 KB |
testcase_07 | AC | 50 ms
50,128 KB |
testcase_08 | AC | 51 ms
50,532 KB |
testcase_09 | AC | 49 ms
50,084 KB |
testcase_10 | AC | 50 ms
50,288 KB |
testcase_11 | AC | 47 ms
50,072 KB |
testcase_12 | AC | 49 ms
50,612 KB |
testcase_13 | AC | 48 ms
50,408 KB |
testcase_14 | AC | 47 ms
50,300 KB |
testcase_15 | AC | 49 ms
50,320 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 48 ms
50,608 KB |
testcase_19 | AC | 48 ms
49,948 KB |
testcase_20 | AC | 48 ms
50,528 KB |
testcase_21 | AC | 48 ms
50,528 KB |
testcase_22 | AC | 47 ms
50,336 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 49 ms
50,360 KB |
testcase_30 | AC | 48 ms
50,328 KB |
testcase_31 | AC | 48 ms
50,332 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; class No345 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); int CW = str.indexOf("cw"); int C = 0; int W1 = 0; int W2 = 0; if (CW != -1) W2 = str.indexOf("w",CW+1); else { C =str.indexOf("c"); //cの位置 W1 = str.indexOf("w",C+1); //1つ目のwの位置 W2 = str.indexOf("w",W1+1); //2つ目のwの位置 } if (CW != -1 && W2 != -1) System.out.println( (W2 - CW) + 2); //"cw"と"w"がある時 else if (CW == -1 && C != -1 && W1 != -1 && W2 != -1 ) //"cw"がないが、cww全てが含まれる時 System.out.println( (W2 - C) + 1 ); else System.out.println(-1); } }