結果

問題 No.345 最小チワワ問題
ユーザー komori3
提出日時 2017-08-25 21:03:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 433 bytes
コンパイル時間 652 ms
コンパイル使用メモリ 56,240 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-25 12:02:51
合計ジャッジ時間 1,415 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;
#define INF 1000
#define MIN(a,b) ((a)<(b)?(a):(b))
#define FOR(i,a,b) for (int i=(a);i<(b);i++)

int main()
{
	int n, len = INF;
	string s;
	cin >> s;

	n = s.size();
	FOR(i, 0, n){		if (s[i] == 'c') {
	FOR(j, i + 1, n) {	if (s[j] == 'w') {
	FOR(k, j + 1, n) {	if (s[k] == 'w') {
		len = MIN(k - i + 1, len);
	}}}}}}

	cout << (len == INF ? -1 : len) << endl;
	return 0;
}
0