結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
gotutiyan
|
| 提出日時 | 2017-11-15 23:46:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 840 bytes |
| コンパイル時間 | 886 ms |
| コンパイル使用メモリ | 82,172 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-25 12:06:09 |
| 合計ジャッジ時間 | 2,177 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long
int mod=1e9+7;
const int INF = 1e9;
using namespace std;
int main(void) {
string s;
cin >> s;
int minn = INF;
bool judge = true;
rep(i, 0, s.length()) {
if (s[i] == 'c') {
int w = 0;
rep(j, i, s.length()) {
if (s[j] == 'w') {
if (w == 0)w++;
else if (w == 1) {
minn = min(minn, j - i + 1);
judge = false;
break;
}
}
}
}
}
if (judge)cout << -1 << endl;
else cout << minn << endl;
return 0;
}
gotutiyan