結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2017-04-07 14:49:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 554 bytes |
コンパイル時間 | 1,506 ms |
コンパイル使用メモリ | 166,756 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-16 00:31:08 |
合計ジャッジ時間 | 2,644 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 12 |
ソースコード
#include "bits/stdc++.h" #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(int i=0;i<N;++i) typedef long long int LL; std::string S; int seek, ans = 100; bool c = false, w = false; int main() { in >> S; rep(i, S.length()) { if (c && w && S[i] == 'w') { ans = std::min(ans, i - seek + 1); c = w = false; } if (S[i] == 'c') { c = true; seek = i; } if (S[i] == 'w' && c) { w = true; } } ans = ((ans == 100) ? (-1) : (ans)); out << ans << std::endl; return 0; }