QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372917 | #2432. Go with the Flow | TWTP_TCTF# | AC ✓ | 9593ms | 7236kb | C++17 | 1.4kb | 2024-03-31 20:46:09 | 2024-03-31 20:46:09 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e6 + 5, mod = 1e9 + 7, A = 26;
int last[N], mx[N], id = 0, n;
vector<string> s;
int mxval(int i) {
int ans = 0;
if (last[i] == id - 1)
ans = max(ans, mx[i]);
if (last[i - 1] == id - 1)
ans = max(ans, mx[i - 1]);
if (last[i + 1] == id - 1)
ans = max(ans, mx[i + 1]);
return ans + 1;
}
int getmax(int len) {
int rem = len, ans = 0, i = 0;
id += 2;
for (auto it: s) {
if (it.size() + (rem != len) > rem) {
id++;
rem = len;
i = 0;
}
if (i) {
mx[i] = mxval(i);
last[i] = id;
ans = max(ans, mx[i]);
}
bool space=(rem != len);
rem -= it.size() + space;
i += it.size() + space;
}
return ans;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
int mn = 0, total = n;
s = vector<string>(n);
for (auto &it: s) {
cin >> it;
total += it.size();
mn = max(mn, (int) it.size());
}
int ans = -1, ansindex = -1;
for (int i = mn; i <= total; i++) {
int res = getmax(i);
if (res > ans) {
ans = res;
ansindex = i;
}
}
cout << ansindex << " " << ans << "\n";
return 0;
}
Details
Test #1:
score: 100
Accepted
time: 1ms
memory: 3684kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3568kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3624kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 3664kb
Test #6:
score: 0
Accepted
time: 1ms
memory: 3620kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 3684kb
Test #8:
score: 0
Accepted
time: 0ms
memory: 3556kb
Test #9:
score: 0
Accepted
time: 0ms
memory: 3704kb
Test #10:
score: 0
Accepted
time: 1ms
memory: 3684kb
Test #11:
score: 0
Accepted
time: 1ms
memory: 3688kb
Test #12:
score: 0
Accepted
time: 1ms
memory: 3572kb
Test #13:
score: 0
Accepted
time: 81ms
memory: 3724kb
Test #14:
score: 0
Accepted
time: 82ms
memory: 5764kb
Test #15:
score: 0
Accepted
time: 82ms
memory: 3772kb
Test #16:
score: 0
Accepted
time: 1900ms
memory: 4132kb
Test #17:
score: 0
Accepted
time: 1840ms
memory: 4036kb
Test #18:
score: 0
Accepted
time: 1798ms
memory: 4028kb
Test #19:
score: 0
Accepted
time: 298ms
memory: 3860kb
Test #20:
score: 0
Accepted
time: 159ms
memory: 3836kb
Test #21:
score: 0
Accepted
time: 5430ms
memory: 6724kb
Test #22:
score: 0
Accepted
time: 9416ms
memory: 5544kb
Test #23:
score: 0
Accepted
time: 52ms
memory: 3748kb
Test #24:
score: 0
Accepted
time: 157ms
memory: 3756kb
Test #25:
score: 0
Accepted
time: 3282ms
memory: 4412kb
Test #26:
score: 0
Accepted
time: 3331ms
memory: 4488kb
Test #27:
score: 0
Accepted
time: 3396ms
memory: 4508kb
Test #28:
score: 0
Accepted
time: 755ms
memory: 3956kb
Test #29:
score: 0
Accepted
time: 834ms
memory: 6072kb
Test #30:
score: 0
Accepted
time: 832ms
memory: 3976kb
Test #31:
score: 0
Accepted
time: 8632ms
memory: 5392kb
Test #32:
score: 0
Accepted
time: 4470ms
memory: 4588kb
Test #33:
score: 0
Accepted
time: 3929ms
memory: 4656kb
Test #34:
score: 0
Accepted
time: 49ms
memory: 3768kb
Test #35:
score: 0
Accepted
time: 0ms
memory: 3616kb
Test #36:
score: 0
Accepted
time: 5210ms
memory: 4572kb
Test #37:
score: 0
Accepted
time: 8767ms
memory: 5448kb
Test #38:
score: 0
Accepted
time: 8709ms
memory: 7236kb
Test #39:
score: 0
Accepted
time: 8513ms
memory: 5116kb
Test #40:
score: 0
Accepted
time: 8745ms
memory: 5148kb
Test #41:
score: 0
Accepted
time: 8961ms
memory: 6716kb
Test #42:
score: 0
Accepted
time: 8771ms
memory: 5440kb
Test #43:
score: 0
Accepted
time: 8946ms
memory: 5500kb
Test #44:
score: 0
Accepted
time: 8747ms
memory: 5392kb
Test #45:
score: 0
Accepted
time: 8198ms
memory: 6684kb
Test #46:
score: 0
Accepted
time: 7958ms
memory: 5052kb
Test #47:
score: 0
Accepted
time: 8111ms
memory: 7132kb
Test #48:
score: 0
Accepted
time: 7879ms
memory: 4976kb
Test #49:
score: 0
Accepted
time: 9127ms
memory: 5260kb
Test #50:
score: 0
Accepted
time: 8929ms
memory: 6936kb
Test #51:
score: 0
Accepted
time: 8327ms
memory: 5136kb
Test #52:
score: 0
Accepted
time: 8148ms
memory: 5132kb
Test #53:
score: 0
Accepted
time: 6900ms
memory: 4896kb
Test #54:
score: 0
Accepted
time: 2ms
memory: 3696kb
Test #55:
score: 0
Accepted
time: 310ms
memory: 3904kb
Test #56:
score: 0
Accepted
time: 27ms
memory: 3640kb
Test #57:
score: 0
Accepted
time: 9194ms
memory: 5488kb
Test #58:
score: 0
Accepted
time: 9593ms
memory: 6812kb
Test #59:
score: 0
Accepted
time: 364ms
memory: 4028kb
Test #60:
score: 0
Accepted
time: 200ms
memory: 3908kb
Test #61:
score: 0
Accepted
time: 2ms
memory: 3592kb
Test #62:
score: 0
Accepted
time: 144ms
memory: 3752kb
Test #63:
score: 0
Accepted
time: 1090ms
memory: 6176kb
Test #64:
score: 0
Accepted
time: 463ms
memory: 3932kb
Test #65:
score: 0
Accepted
time: 7555ms
memory: 6596kb
Test #66:
score: 0
Accepted
time: 0ms
memory: 3608kb