結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2016-09-28 00:51:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 820 bytes |
コンパイル時間 | 624 ms |
コンパイル使用メモリ | 79,220 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 11:53:55 |
合計ジャッジ時間 | 1,524 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include<stdio.h> #include <vector> #include <list> #include <map> #include <set> #include <queue> #include <stack> #include <algorithm> #include <sstream> #include <iostream> #include <string> #include <stdio.h> using namespace std; int main() { string S; cin >> S; int ans = 999, sta = 0; bool flag; for (int l = 0; l < S.size(); l++) { if (S[l] == 'c') { flag = false; for (int m = l + 1; m < S.size() - 1; m++) { if (S[m] == 'w' && !flag) { for (int r = m+1; r < S.size(); r++) { if (S[r] == 'w') { ans = min(ans, r-l+1); //cout << "l: " << l << " m: " << m << " r: " << r << " ans: " << ans << endl; flag = true; break; } } if (flag) break; } } } } if (ans == 999) cout << -1 << endl; else cout << ans << endl; return 0; }