結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-09 01:58:25 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 749 bytes |
| 記録 | |
| コンパイル時間 | 600 ms |
| コンパイル使用メモリ | 71,916 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-23 15:37:22 |
| 合計ジャッジ時間 | 2,080 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 6 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:11:9: warning: 'count' may be used uninitialized [-Wmaybe-uninitialized]
11 | if(count == 2) break;
| ^~
main.cpp:8:9: note: 'count' was declared here
8 | int count;
| ^~~~~
main.cpp:19:42: warning: 'temae' may be used uninitialized [-Wmaybe-uninitialized]
19 | for(int k = 0; k < temae ; k++) if(cww[k] == 'c') i = k;
| ~~^~~~~~~
main.cpp:9:9: note: 'temae' was declared here
9 | int temae;
| ^~~~~
ソースコード
#include <iostream>
#include <string>
using namespace std;
int main(){
string cww; cin >> cww;
int len = cww.size();
int count;
int temae;
for(int i = 0; i < len-2; i++){
if(count == 2) break;
count = 0;
if(cww[i] == 'c'){
for(int j = i+1; j < len; j++){
if(cww[j] == 'w'){
count += 1;
if(count == 1) temae = j;
if(count == 2){
for(int k = 0; k < temae ; k++) if(cww[k] == 'c') i = k;
cout << j - i + 1 << endl;
break;
}
}
}
}
}
if(count != 2) cout << -1 << endl;
return 0;
}