結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
sk3388607083
|
| 提出日時 | 2018-06-22 16:25:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 376 bytes |
| コンパイル時間 | 109 ms |
| コンパイル使用メモリ | 22,656 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 17:59:22 |
| 合計ジャッジ時間 | 1,163 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | AC * 8 WA * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%s", S);
| ~~~~~^~~~~~~~~
ソースコード
#include<stdio.h>
int main(void){
int i;
char S[101];
int flag = 0, n = 0;
scanf("%s", S);
for(i = 0; S[i] != '\0'; i++){
if(S[i] == 'c') flag = 1;
if(flag == 1 && S[i] == 'w') flag = 2;
else if(flag == 2 && S[i] == 'w'){
flag = 3;
break;
}
if(flag != 0) n++;
}
if(n == 0) printf("-1\n");
else printf("%d\n", n);
return 0;
}
sk3388607083