結果

問題 No.345 最小チワワ問題
ユーザー koyumeishikoyumeishi
提出日時 2016-02-26 22:23:09
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,127 bytes
コンパイル時間 831 ms
コンパイル使用メモリ 88,292 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-25 11:21:16
合計ジャッジ時間 1,574 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <set>
#include <ctime>
#include <random>
using namespace std;
template<typename T> istream& operator >> (istream& is, vector<T>& vec){for(T& val: vec) is >> val; return is;}
template<typename T> istream& operator , (istream& is, T& val){ return is >> val;}
template<typename T> ostream& operator << (ostream& os, const vector<T>& vec){for(int i=0; i<vec.size(); i++) os << vec[i] << (i==vec.size()-1?"\n":" ");return os;}
template<typename T> ostream& operator , (ostream& os, T& val){ return os << " " << val;}
template<typename T> ostream& operator >> (ostream& os, T& val){ return os << " " << val;}

using namespace std;

int main(){
	string s;
	cin >> s;

	int ans = 114514;
	for(int i=0; i<s.size(); i++){
		if(s[i] == 'c') for(int j=i+1; j<s.size(); j++){
			if(s[j] == 'w') for(int k=j+1; k<s.size(); k++){
				if(s[k] == 'w') ans = min(ans, k-i+1);
			}
		}
	}
	if(ans == 114514) ans = -1;
	cout << ans << endl;
	return 0;
}
0