結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
![]() |
提出日時 | 2018-08-06 17:10:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 753 bytes |
コンパイル時間 | 1,605 ms |
コンパイル使用メモリ | 170,972 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-19 18:17:16 |
合計ジャッジ時間 | 2,949 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} //INSERT ABOVE HERE signed main(){ Int d; cin>>d; string s,t; cin>>s>>t; s+=t; s=string(100,'x')+s+string(100,'x'); auto calc= [](string s){ Int n=s.size(); Int res=0; for(Int i=0;i<n;i++){ Int j=i; while(j<n&&s[j]=='o') j++; chmax(res,j-i); } return res; }; Int n=s.size(); Int ans=0; for(Int i=0;i<n;i++){ t=s; for(Int j=0;j<d&&i+j<n;j++) if(s[i+j]=='x') t[i+j]='o'; else break; chmax(ans,calc(t)); } cout<<ans<<endl; return 0; }