結果

問題 No.345 最小チワワ問題
ユーザー kotamanegikotamanegi
提出日時 2016-02-26 22:26:52
言語 C++11
(gcc 13.3.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 892 bytes
コンパイル時間 920 ms
コンパイル使用メモリ 80,904 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-15 22:58:13
合計ジャッジ時間 3,152 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <list>
#include <typeinfo>
using namespace std;
#define REP(a,b) for(long long a = 0;a < b;++a)
int main() {
	string hoge;
	cin >> hoge;
	int ans = 300;
	for (int i = 0;i < hoge.length()-2;++i) {
		if (hoge[i] == 'c') {
			for (int q = i+1;q < hoge.length()-1;++q) {
				if (hoge[q] == 'w') {
					for (int j = q + 1;j < hoge.length();++j) {
						if (hoge[j] == 'w') {
							ans = min(ans, j - i+1);
						}
					}
				}
			}
		}
	}
	if (ans == 300) {
		cout << "-1" << endl;
	}
	else {
		cout << ans << endl;
	}
}
//thank you for reading my code!
0