結果

問題 No.345 最小チワワ問題
ユーザー Mizuno
提出日時 2024-11-13 09:20:42
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 412 bytes
コンパイル時間 1,181 ms
コンパイル使用メモリ 80,128 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-13 09:20:44
合計ジャッジ時間 2,146 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 18 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

int main() {
	
	string s;
	cin >> s;
	int ans = 0;
	int w = 0;
	bool f = false;
	int l = s.size();
	for(int i = 0; i < l; i++) {
		if(s[i] == 'c') {
			
			if(f) {
			    ans = 0;
			    w = 0;
			}
			
			f = true;
			
		}
		if(f){
		    ans++;
		    if(s[i] == 'w') {
				w++;
			}
			
			if(w == 2)break;
		    
		}
	}
	if(ans == 0)cout << -1;
	else cout << ans;
	
}
0