結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
h_tyokinuhata
|
| 提出日時 | 2016-02-27 02:44:19 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 691 bytes |
| コンパイル時間 | 2,209 ms |
| コンパイル使用メモリ | 75,044 KB |
| 実行使用メモリ | 54,440 KB |
| 最終ジャッジ日時 | 2024-09-24 11:00:56 |
| 合計ジャッジ時間 | 7,063 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 21 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String S = sc.next();
String comp = S;
int flag = 0;
for(int i = 0; i < S.length(); i++) {
if(S.substring(i, i + 1).equals("c")) {
S = S.substring(i);
comp = S;
//System.out.println(S);
S = S.substring(S.indexOf("w") + 1);
//System.out.println(S);
if(S.indexOf("w") == -1) {
flag = 1;
break;
} else {
S = S.substring(S.indexOf("w") + 1);
//System.out.println(S);
}
}
}
if(flag == 0) {
System.out.println(comp.length() - S.length());
} else {
System.out.println(-1);
}
}
}
h_tyokinuhata