結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2020-03-14 20:05:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 522 bytes |
コンパイル時間 | 1,708 ms |
コンパイル使用メモリ | 167,476 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-23 21:27:26 |
合計ジャッジ時間 | 2,837 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> #define int long long using namespace std; signed main(){ string S; cin >> S; int ans = 10000000; for( int i = 0; i < S.size(); i++ ){ if( S.at(i) == 'c' ){ int cnt = 1; bool fg1 = false; for( int j = i+1; j < S.size(); j++ ){ cnt++; if( S.at(j) == 'w' && fg1 == false ) fg1 = true; else if( S.at(j) == 'w' && fg1 == true ) ans = min(cnt, ans); } } } if( ans != 10000000 ) cout << ans << endl; else cout << -1 << endl; }