結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
hiyokko2
|
| 提出日時 | 2017-08-09 11:33:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 616 bytes |
| コンパイル時間 | 1,258 ms |
| コンパイル使用メモリ | 158,336 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-25 12:02:41 |
| 合計ジャッジ時間 | 2,205 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;
signed main()
{
string S;
cin >> S;
int ans = 999;
REP(i,S.length()) {
if (S[i] == 'c') {
int cnt = 0;
for (int j=i+1; j<S.length(); j++) {
if (S[j] == 'w') cnt++;
if (cnt == 2) {
ans = min(ans, j - i + 1);
}
}
}
}
cout << (ans == 999 ? -1 : ans) << endl;
}
hiyokko2