QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#780181 | #2432. Go with the Flow | LJY_ljy | TL | 2793ms | 4052kb | C++11 | 1.2kb | 2024-11-25 07:08:39 | 2024-11-25 07:08:39 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
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;
map<int, 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 + MAXM; 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][Len] = 1;
int A = 0;
if (G[eid1 - 1][Len - 1]) A = max(A, cnt[Len - 1]);
if (G[eid1 - 1][Len]) A = max(A, cnt[Len]);
if (G[eid1 - 1][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.first] = 0;
}
G[i].clear();
}
if (maxx > ans) {
ans = maxx;
ansx = gap;
}
}
cout << ansx << " " << ans << endl;
return 0;
}
Details
Test #1:
score: 100
Accepted
time: 4ms
memory: 3772kb
Test #2:
score: 0
Accepted
time: 2ms
memory: 3780kb
Test #3:
score: 0
Accepted
time: 1ms
memory: 3704kb
Test #4:
score: 0
Accepted
time: 6ms
memory: 3792kb
Test #5:
score: 0
Accepted
time: 49ms
memory: 3860kb
Test #6:
score: 0
Accepted
time: 11ms
memory: 3852kb
Test #7:
score: 0
Accepted
time: 5ms
memory: 3844kb
Test #8:
score: 0
Accepted
time: 5ms
memory: 3708kb
Test #9:
score: 0
Accepted
time: 5ms
memory: 3788kb
Test #10:
score: 0
Accepted
time: 5ms
memory: 3708kb
Test #11:
score: 0
Accepted
time: 7ms
memory: 3780kb
Test #12:
score: 0
Accepted
time: 11ms
memory: 3852kb
Test #13:
score: 0
Accepted
time: 2744ms
memory: 4052kb
Test #14:
score: 0
Accepted
time: 2762ms
memory: 3996kb
Test #15:
score: 0
Accepted
time: 2793ms
memory: 4000kb
Test #16:
score: -100
Time Limit Exceeded