#include #include /* * [No.345 最小チワワ問題 - yukicoder](http://yukicoder.me/problems/984 "No.345 最小チワワ問題 - yukicoder") * 提出者 : まろ * 使用言語 C++ */ using namespace std; auto chiwawa_length(int start, string s) -> size_t { auto index = s.find('w', start + 1); if (index != (size_t)-1) index = s.find('w', index + 1); if (index == (size_t)-1) return -1; return index - start + 1; } auto main() -> int { string s; cin >> s; char c = 'c'; auto index = s.find(c); auto min_length = numeric_limits::max(); while (index != (size_t)-1) { min_length = min(chiwawa_length(index, s), min_length); index = s.find(c, index + 1); } if (min_length == numeric_limits::max()) cout << -1 << endl; else cout << min_length << endl; return 0; }