結果
問題 | No.345 最小チワワ問題 |
ユーザー |
![]() |
提出日時 | 2016-03-04 15:09:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 661 bytes |
コンパイル時間 | 593 ms |
コンパイル使用メモリ | 57,960 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 11:36:42 |
合計ジャッジ時間 | 1,516 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include<iostream> #include <algorithm> using namespace std; int main() { string s; cin >> s; int result = -1; for (int i = 0; i < s.length(); i++) { if (s[i] == 'c') { for(int j = i + 1; j < s.length(); j++) { if(s[j] == 'w') { for(int k = j + 1;k < s.size();k++){ if(s[k] == 'w'){ if(result == -1) result = k - i + 1; else result = min(result,k - i + 1); } } } } } } cout << result << endl; return 0; }