結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー fura
提出日時 2020-04-25 21:42:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 616 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 196,912 KB
最終ジャッジ日時 2025-01-10 01:40:48
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

vector<pair<char,int>> run_length_encoding(const string& s){
	vector<pair<char,int>> res;
	int n=s.length(),pre=0;
	rep(i,n) if(i==n-1 || s[i]!=s[i+1]) res.emplace_back(s[i],i-pre+1), pre=i+1;
	return res;
}

int main(){
	int d;
	string s1,s2; cin>>d>>s1>>s2;

	string s=string(14,'x')+s1+s2+string(14,'x');

	int ans=0;
	rep(i,42){
		string t=s;
		rep(j,d){
			if(i+j>=42 || t[i+j]=='o') break;
			t[i+j]='o';
		}
		for(auto p:run_length_encoding(t)) if(p.first=='o') ans=max(ans,p.second);
	}
	cout<<ans<<'\n';

	return 0;
}
0