結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-27 00:39:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 764 bytes |
| 記録 | |
| コンパイル時間 | 582 ms |
| コンパイル使用メモリ | 56,792 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-24 10:48:21 |
| 合計ジャッジ時間 | 1,354 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 9 |
ソースコード
#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;
std::string::size_type pos = -1;
if ((pos = s.find('c', pos + 1)) == std::string::npos) {
std::cout << -1 << std::endl;
return EXIT_SUCCESS;
} else {
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) {
std::cout << -1 << std::endl;
return EXIT_SUCCESS;
} else {
ps[idx++] = pos;
}
}
std::cout << (ps[2] - ps[0] + 1) << std::endl;
return EXIT_SUCCESS;
}