QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#780178 | #2432. Go with the Flow | LJY_ljy | WA | 1ms | 3752kb | C++11 | 1.2kb | 2024-11-25 06:59:28 | 2024-11-25 06:59:29 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
const int MAXN = 100;
const int MAXM = 3000;
char str[MAXN];
int n, len[MAXM], minn, sum, eid, maxx, cnt[MAXN * MAXM], ans, ansx;
set<int> G[MAXM];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> str + 1;
len[i] = strlen(str + 1);
minn = max(minn, len[i]);
sum += len[i];
}
for (int gap = minn; gap <= sum; gap++) {
int maxx = 0;
int j = 1, Len = 0, eid1 = 0;
while (j <= n) {
++eid1;
while (Len + len[j] <= gap && j <= n) {
Len = Len + len[j] + 1;
if (Len + len[j + 1] <= gap && j < n) {
G[eid1].insert(Len);
int A = 0;
if (G[eid1 - 1].count(Len - 1)) A = max(A, cnt[Len - 1]);
if (G[eid1 - 1].count(Len)) A = max(A, cnt[Len]);
if (G[eid1 - 1].count(Len + 1)) A = max(A, cnt[Len + 1]);
cnt[Len] = A + 1;
maxx = max(maxx, cnt[Len]);
}
j++;
}
Len = 0;
}
for (int i = 1; i <= eid1; i++) {
for (auto x:G[i]) {
cnt[x] = 0;
}
G[i].clear();
}
if (maxx > ans) {
ans = maxx;
ansx = gap;
}
}
cout << ansx << " " << ans << endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3752kb
Test #2:
score: 0
Accepted
time: 1ms
memory: 3692kb
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3712kb