結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
f843nmfwisfeuw
|
| 提出日時 | 2020-06-12 19:59:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 921 bytes |
| コンパイル時間 | 841 ms |
| コンパイル使用メモリ | 91,528 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-24 04:11:01 |
| 合計ジャッジ時間 | 2,017 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 RE * 1 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>
using namespace std;
int main() {
string S;
cin >> S;
bool found = false;
int tmpC=0;
int ans = S.size();
for (int i = 0; i < S.size() - 2; ++i) {
if (S[i] == 'c') {
tmpC = i;
int cnt = 0;
for (int j = i + 1; j < S.size(); ++j) {
if (S[j] == 'w') {
cnt += 1;
if (cnt == 2) {
found = true;
ans = min(ans,j - tmpC + 1);
break;
}
}
}
}
}
if(found) {
cout << ans << endl;
} else {
cout << -1 << endl;
}
return 0;
}
f843nmfwisfeuw