結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー Kmcode1Kmcode1
提出日時 2015-05-08 22:30:19
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,110 bytes
コンパイル時間 1,268 ms
コンパイル使用メモリ 92,960 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 11:35:58
合計ジャッジ時間 2,306 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
using namespace std;
string s;
int solve(){
	int countt = 0;
	int maxt = 0;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'o'){
			countt++;
			maxt = max(maxt, countt);
		}
		else{
			countt = 0;
		}
	}
	return maxt;
}
char ss = 'o';
int main(){
	int d;
	cin >> d;
	cin >> s;
	string t;
	cin >> t;
	s += t;
	string k;
	k.clear();
	for (int i = 0; i < d+1; i++){
		k.push_back('x');
	}
	s += k;
	s = k + s;
	string tmp=s;
	int ans = 0;
	for (int i = 0; i < s.size(); i++){
		s = tmp;
		bool ok = false;
		for (int j = i; j < s.size() && j < i + d; j++){
			if (s[j] == ss){
				break;
			}
			s[j] = ss;
		}

			ans = max(ans, solve());
	}
	cout << ans << endl;
	return 0;
}
0