結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-16 13:46:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 730 bytes |
| コンパイル時間 | 641 ms |
| コンパイル使用メモリ | 72,300 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-07 02:23:02 |
| 合計ジャッジ時間 | 1,333 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
string s;
cin >> s;
vector<int> c_id;
for (int i = 0; i < s.length(); i++) {
if (s[i] == 'c') {
c_id.push_back(i);
}
}
int cww_len = 1000;
for (int i : c_id) {
int ct_w = 0;
for (int j = i + 1; j < s.length(); j++) {
if (s[j] == 'w') {
ct_w++;
if (ct_w == 2) {
cww_len = min(cww_len, j - i + 1);
}
}
}
}
if (cww_len == 1000)
{
cout << -1 << endl;
} else {
cout << cww_len << endl;
}
return 0;
}