QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#380781#2432. Go with the Flowckiseki#WA 32ms3804kbC++202.0kb2024-04-07 12:00:352024-04-07 12:00:36

Judging History

你现在查看的是最新测评结果

  • [2024-04-07 12:00:36]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:3804kb
  • [2024-04-07 12:00:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(auto s, auto ...a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
#include <experimental/iterator>
void orange_(auto s, auto L, auto R) {
  cerr << "\e[1;33m[ " << s << " ] = [ ";
  using namespace experimental;
  copy(L, R, make_ostream_joiner(cerr, ", "));
  cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> a(n);
  for (auto &ai : a)
    cin >> ai;

  auto solve = [&](int l) {
    int ans = 1;
    vector<pair<int, int>> pre;
    int p = 0;
    while (p < n) {
      vector<pair<int, int>> cur;
      int w = 0;
      while (w < l and p < n) {
        int curw = int(a[p].size()) + !!w;
        if (w + curw > l)
          break;
        w += curw;
        p += 1;
        cur.emplace_back(w, 1);
      }
      cur.pop_back();

      size_t o = 0;
      for (auto &[y, v] : cur) {
        while (o < pre.size()) {
          if (pre[o].first + 1 < y)
            o += 1;
          else
            break;
        }
        if (o == pre.size())
          continue;
        if (abs(pre[o].first - y) <= 1) {
          v = max(v, pre[o].second + 1);
        }
        if (o + 1 < pre.size() and abs(pre[o + 1].first - y) <= 1) {
          v = max(v, pre[o + 1].second + 1);
        }
        ans = max(ans, v);
      }
      pre = cur;
    }
    return ans;
  };

  int len = 0;
  for (const auto &ai : a)
    len = max(len, int(ai.size()));

  pair<int, int> ans = {0, 0};
  for (int l = len; l < 2500 * 81; ++l)
    ans = max(ans, pair{solve(l), -l});
  cout << -ans.second << ' ' << ans.first << '\n';
  return 0;
}

Details

Test #1:

score: 100
Accepted
time: 30ms
memory: 3584kb

Test #2:

score: 0
Accepted
time: 32ms
memory: 3804kb

Test #3:

score: -100
Wrong Answer
time: 7ms
memory: 3584kb