結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2016-02-28 00:39:18 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 515 bytes |
コンパイル時間 | 507 ms |
コンパイル使用メモリ | 55,260 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 11:32:44 |
合計ジャッジ時間 | 1,417 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:40: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings] 13 | char *search = "cww "; | ^~~~~~
ソースコード
//ループ愚直全探索は☆1ですかね… #include <iostream> #include <string> using namespace std; int main(){ string s; int ans = 364; cin >> s; for( int l = 0; l < s.length(); l++ ){ for( int r = l; r < s.length(); r++ ){ char *search = "cww "; int cor = 0; for( int i = l; i <= r; i++ ){ if( s[i] == search[cor] ){ cor++; } } if( cor == 3 ){ ans = min(r - l + 1, ans); } } } if( ans == 364 ) cout << -1 << endl; else cout << ans << endl; return 0; }