結果
問題 | No.38 赤青白ブロック |
ユーザー | ttkkggww |
提出日時 | 2022-04-01 11:45:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 251 ms / 5,000 ms |
コード長 | 800 bytes |
コンパイル時間 | 3,864 ms |
コンパイル使用メモリ | 250,952 KB |
最終ジャッジ日時 | 2025-01-28 13:33:26 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
#include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; using ll = long long; int r,b; string s; void solve(){ int ans =0; for(int bit = 0;bit<(1<<20);bit++){ string t; int j = 0; for(int i =0;i<30;i++){ if(s[i]=='W'){ t.push_back('W'); }else{ if((bit>>j)&1){ t.push_back(s[i]); } j++; } } bool is = true; for(int i =0;i<t.size();i++){ if(t[i]=='W')continue; int L = i - (t[i]=='R'?r:b),R = i + (t[i]=='R'?r:b); if(L>=0&&L<(int)t.size()){ if(t[i]==t[L])is = false; } if(R>=0&&R<(int)t.size()){ if(t[i]==t[R])is = false; } } if(is)ans = max(ans,(int)t.size()); } cout<<ans<<endl; } signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cin >> r >> b; cin >> s; solve(); }