QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#380781 | #2432. Go with the Flow | ckiseki# | WA | 32ms | 3804kb | C++20 | 2.0kb | 2024-04-07 12:00:35 | 2024-04-07 12:00:36 |
Judging History
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;
}
詳細信息
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