結果
問題 | No.345 最小チワワ問題 |
ユーザー |
![]() |
提出日時 | 2016-03-04 00:08:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 462 bytes |
コンパイル時間 | 574 ms |
コンパイル使用メモリ | 62,236 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 11:36:26 |
合計ジャッジ時間 | 1,324 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream> #include <sstream> #include <algorithm> #include <vector> using namespace std; int main(int argc, char *argv[]) { string s; cin >> s; unsigned int ans = -1; for (int i = 1; i != s.length(); ++i) { if (s[i] == 'w') { int a = s.substr(0, i).rfind('c'); if (a >= 0) { int b = s.substr(i + 1).find('w'); if (b >= 0) { ans = min(ans, (unsigned)(i - a + b + 2)); } } } } cout << (int)ans << endl; return 0; }