結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-19 00:43:02 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 830 bytes |
| 記録 | |
| コンパイル時間 | 2,437 ms |
| コンパイル使用メモリ | 80,616 KB |
| 実行使用メモリ | 39,296 KB |
| 最終ジャッジ日時 | 2026-05-08 09:56:59 |
| 合計ジャッジ時間 | 3,889 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 10 |
ソースコード
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);
}
}