結果

問題 No.345 最小チワワ問題
ユーザー Kura
提出日時 2019-02-26 22:14:13
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 468 bytes
コンパイル時間 721 ms
コンパイル使用メモリ 56,072 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-06-23 04:56:30
合計ジャッジ時間 4,511 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
using namespace std;
int main() {
	string s; cin >> s; int ans = s.length() + 1;
	for (int i = 0; i < s.length() - 2; i++) {
		for (int j = 2; i + j < s.length(); j++) {
			if (s[i] == 'c'&&s[i + j] == 'w') {
				for (int k = i + 1; k < i + j; k++) {
					if (s[k] == 'w') {
						ans = min(ans, j + 1);
						break;
					}
				}
			}
		}
	}
	if (ans == s.length() + 1) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
}
0