結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー |
![]() |
提出日時 | 2016-07-23 12:10:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,037 bytes |
コンパイル時間 | 561 ms |
コンパイル使用メモリ | 63,396 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 09:27:33 |
合計ジャッジ時間 | 1,957 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 WA * 1 |
ソースコード
#include<iostream>#include<string>#include<algorithm>using namespace std;int cal(string s){int ret=0, cnt=0;for(int i=0; i<s.size(); i++){if(s[i]=='o'){cnt++;ret=max(ret, cnt);}else{cnt=0;}}return ret;}int main(){int D;cin>> D;string c1, c2;cin>> c1>> c2;auto str=c1+c2;auto C=string(14, 'x')+str+string(14, 'x');auto B=C;reverse(B.begin(), B.end());int ans=-1;for(int i=0; i<=42-D; i++){auto s=C.substr(0, i), t=B.substr(0, i);int d=D;while(d){if(C.substr(i, d)==string(d, 'x')){ s+=string(d, 'o'); break;}d--;}d=D;while(d){if(B.substr(i, d)==string(d, 'x')){ t+=string(d, 'o'); break;}d--;}for(int j=s.size(); j<42; j++){s+=C[j];t+=B[j];}ans=max(ans, max(cal(s), cal(t)));}cout<< ans<< endl;return 0;}