結果
問題 | No.38 赤青白ブロック |
ユーザー | ttkkggww |
提出日時 | 2022-03-31 10:42:26 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 806 bytes |
コンパイル時間 | 4,384 ms |
コンパイル使用メモリ | 268,676 KB |
実行使用メモリ | 1,031,936 KB |
最終ジャッジ日時 | 2024-04-28 04:00:33 |
合計ジャッジ時間 | 17,027 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | MLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
ソースコード
#include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; using ll = long long; int r,b; string s; bool chk(string &s){ bool is = true; for(int i = 0;i<s.size();i++){ if(s[i]=='W')continue; int l = i - (s[i]=='R'?r:b); if(l>=0){ if(s[i]==s[l])is=false; } } return is; } void solve(){ set<string> st; st.insert(""); for(int i = 0;i<30;i++){ set<string> nst; for(auto &j:st){ auto t = j; if(chk(t)){ nst.insert(t); } t.push_back(s[i]); if(chk(t)){ nst.insert(t); } } //cout<<nst.size()<<endl; swap(st,nst); } int ans = 0; //cout<<st.size()<<endl; for(auto &i:st)ans=max(ans,(int)i.size()); cout<<ans<<endl; } signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cin >> r >> b; cin >> s; solve(); }