結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-27 00:54:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 809 bytes |
| コンパイル時間 | 684 ms |
| コンパイル使用メモリ | 56,648 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-24 10:50:11 |
| 合計ジャッジ時間 | 1,664 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 18 |
ソースコード
#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, 0, 0};
int idx = 1;
for (const auto& c : {'w', 'w'}) {
if ((pos = s.find(c, pos + 1)) == std::string::npos) {
break;
} else {
ps[idx++] = pos;
}
}
maxLen = ps[2] - ps[0] + 1;
} while (pos != std::string::npos);
std::cout << maxLen << std::endl;
return EXIT_SUCCESS;
}