結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
tetsuzuki1115
|
| 提出日時 | 2017-09-24 17:52:55 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 736 bytes |
| コンパイル時間 | 679 ms |
| コンパイル使用メモリ | 80,572 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-25 12:03:34 |
| 合計ジャッジ時間 | 1,494 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;
long long MOD = 1000000007;
int main() {
int ans = INT_MAX;
string S;
cin >> S;
for ( int i = 0; i < S.length(); i++ ) {
for ( int j = i+1; j < S.length(); j++ ) {
for ( int k = j+1; k < S.length(); k++ ) {
if ( S[i] == 'c' && S[j] == 'w' && S[k] == 'w' ) {
ans = min( ans, k-i+1 );
}
}
}
}
if ( ans == INT_MAX ) { cout << -1 << endl; }
else { cout << ans << endl; }
return 0;
}
tetsuzuki1115