結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,res;
    int temp{0},temp2=numeric_limits<int>::max();
    cin >> s;
    int len=s.size();
    bool flag=false;
    for(int i=0; i<len; i++){
		for(int j=i+1; j<len; j++){
			for(int k=j+1; k<len; k++){
				if(s[i]=='c'&&s[j]=='w'&&s[k]=='w'){
					res+=s[i]; res+=s[j]; res+=s[k];
					temp=k-i+1;//神point
					if(temp2>temp){
						temp2=temp;
						flag=true;
					}
				}
			}
		}
	}
	cout << (flag?temp2:-1) << endl;
	return 0;
}
0