結果
| 問題 | 
                            No.345 最小チワワ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             prog470
                         | 
                    
| 提出日時 | 2016-09-28 00:30:42 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 708 bytes | 
| コンパイル時間 | 757 ms | 
| コンパイル使用メモリ | 79,384 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-11-21 07:29:07 | 
| 合計ジャッジ時間 | 1,923 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 WA * 15 | 
ソースコード
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	int ans = 0, sta = 0;
	bool flag;
	for (int l = 0; l < S.size(); l++) {
		if (S[l] == 'c') {
			flag = false;
			for (int m = l + 1; m < S.size() - 2; m++) {
				if (S[m] == 'w' && !flag) {
					for (int r = m+1; r < S.size();  r++) {
						if (S[r] == 'w') {
							ans = max(ans, r-l+1);
							flag = true;
							break;
						}
					}
				}
			}
		}
	}
	if (ans == 0) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}
            
            
            
        
            
prog470