結果
問題 |
No.38 赤青白ブロック
|
ユーザー |
|
提出日時 | 2022-03-31 10:42:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 806 bytes |
コンパイル時間 | 3,824 ms |
コンパイル使用メモリ | 257,132 KB |
最終ジャッジ日時 | 2025-01-28 13:29:25 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 TLE * 7 MLE * 11 |
ソースコード
#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(); }