結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
![]() |
提出日時 | 2015-05-28 12:31:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,773 bytes |
コンパイル時間 | 834 ms |
コンパイル使用メモリ | 90,340 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 13:19:58 |
合計ジャッジ時間 | 1,986 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 WA * 6 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <algorithm> // require sort next_permutation count __gcd reverse etc. #include <cstdlib> // require abs exit atof atoi #include <cstdio> // require scanf printf #include <functional> #include <numeric> // require accumulate #include <cmath> // require fabs #include <climits> #include <limits> #include <cfloat> #include <iomanip> // require setw #include <sstream> // require stringstream #include <cstring> // require memset #include <cctype> // require tolower, toupper #include <fstream> // require freopen #include <ctime> // require srand #define rep(i,n) for(int i=0;i<(n);i++) #define ALL(A) A.begin(), A.end() using namespace std; typedef long long ll; typedef pair<int, int> P; const string weekly = "xxxxxxx"; int cnt[50]; int max_holiday (string s ){ memset (cnt, 0, sizeof (cnt ) ); cnt[0] = (s[0] == 'o' ); int n = s.length(); for (int i = 1; i < n; i++ ){ if (s[i] == 'o' ) cnt[i] = cnt[i-1] + 1; else cnt[i] = 0; } // end for int res = 0; rep (i, n ) res = max (res, cnt[i] ); return res; } int main() { ios_base::sync_with_stdio(0); int D; cin >> D; string c1; cin >> c1; string c2; cin >> c2; string s = ""; rep (i, 2 ) s += weekly; s += c1; s += c2; rep (i, 2 ) s += weekly; string t = ""; rep (i, D ) t += 'o'; int res = 0; rep (i, s.length() - t.length() + 1 ){ string u = s; bool ok = true; rep (j, t.length() ){ if (u[i+j] == 'o' ){ ok = false; break; }else{ u[i+j]= t[j]; } // end if } // end rep int curr = 0; if (ok ) curr = max_holiday (u ); res = max (res, curr ); } // end rep cout << res << endl; return 0; }