結果
問題 |
No.291 黒い文字列
|
ユーザー |
![]() |
提出日時 | 2015-10-16 23:36:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 675 bytes |
コンパイル時間 | 686 ms |
コンパイル使用メモリ | 55,792 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-21 20:44:08 |
合計ジャッジ時間 | 1,523 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 WA * 14 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:14:21: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings] 14 | char *sub = "KUROI"; | ^~~~~~~
ソースコード
//自信のない解法。左からgreedyにKUROIを作っていく、?は無視する。 //もう一度左からKUROIを作っていく。 #include <iostream> #include <string> using namespace std; int main() { static string s; static bool used[100] = {false}; cin >> s; char *sub = "KUROI"; int cor = 0, cnt = 0; for( int i = 0; i < s.length(); i++ ){ if( s[i] == sub[cor] ){ cor = (cor + 1) % 5; cnt += (cor == 0); used[i] = true; } } cor = 0; for( int i = 0; i < s.length(); i++ ){ if( (s[i] == sub[cor] || s[i] == '?') && !used[i] ){ cor = (cor + 1) % 5; cnt += (cor == 0); used[i] = true; } } cout << cnt << endl; return 0; }