結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-27 01:03:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 888 bytes |
| コンパイル時間 | 620 ms |
| コンパイル使用メモリ | 57,236 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 10:54:15 |
| 合計ジャッジ時間 | 1,360 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 5 |
ソースコード
#include <cstdlib>
#include <array>
#include <iostream>
#include <string>
int
main()
{
std::cin.tie(0);
std::ios::sync_with_stdio(false);
std::string s;
std::cin >> s;
int maxLen = -1;
std::string::size_type pos = -1, cpos = -1;
do {
if ((cpos = s.find('c', cpos + 1)) == std::string::npos) {
break;
} else {
pos = cpos;
while (pos + 1 < s.length() && s[++pos] == 'c');
pos--;
}
std::array<std::string::size_type, 3> ps{pos, pos, pos};
int idx = 1;
bool isFail = false;
for (const auto& c : {'w', 'w'}) {
if ((pos = s.find(c, pos + 1)) == std::string::npos) {
isFail = true;
break;
} else {
ps[idx++] = pos;
}
}
if (!isFail) {
maxLen = ps[2] - ps[0] + 1;
}
} while (pos != std::string::npos);
std::cout << maxLen << std::endl;
return EXIT_SUCCESS;
}