結果

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);

int calc(const vector<bool> &b) {
  int ret = 0;
  for (int i = 0; i < b.size(); i++) {
    if (!b[i]) continue;
    int j = i;
    while (j < b.size() && b[j]) {
      ++j;
    }
    ret = max(ret, j - i);
    i = j-1;
  }
  return ret;
}


int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int d;
  cin >> d;
  vector<bool> b(14 * 3);

  string s1, s2;
  cin >> s1 >> s2;
  string s = s1 + s2;

  REP (i, 14) {
    if (s[i] == 'o')
      b[14 + i] = true;
  }

  int ret = calc(b);

  for (int i = 0; i + d - 1 < 14 * 3; i++) {
    vector<bool> x = b;
    for (int j = i; j < i + d; j++) {
      if (x[j]) break;
      x[j] = true;
      ret = max(ret, calc(x));
    }
  }

  cout << ret << endl;
  
  return 0;
}
0