QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#372891 | #2432. Go with the Flow | TWTP_TCTF# | WA | 9463ms | 7496kb | C++17 | 1.4kb | 2024-03-31 20:23:51 | 2024-03-31 20:23:53 |
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 (i && 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]);
}
rem -= it.size() + (rem != len);
i += it.size() + (rem != len);
}
return ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
int mn = 1e9, total = n;
s = vector<string>(n);
for (auto &it: s) {
cin >> it;
total += it.size();
mn = min(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;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3568kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3652kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
Test #4:
score: 0
Accepted
time: 1ms
memory: 3572kb
Test #5:
score: 0
Accepted
time: 1ms
memory: 3576kb
Test #6:
score: 0
Accepted
time: 1ms
memory: 3600kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 3564kb
Test #8:
score: 0
Accepted
time: 1ms
memory: 3572kb
Test #9:
score: 0
Accepted
time: 0ms
memory: 3572kb
Test #10:
score: 0
Accepted
time: 1ms
memory: 3624kb
Test #11:
score: 0
Accepted
time: 1ms
memory: 3616kb
Test #12:
score: 0
Accepted
time: 1ms
memory: 3620kb
Test #13:
score: 0
Accepted
time: 82ms
memory: 3716kb
Test #14:
score: 0
Accepted
time: 77ms
memory: 3756kb
Test #15:
score: 0
Accepted
time: 78ms
memory: 3760kb
Test #16:
score: 0
Accepted
time: 1895ms
memory: 4020kb
Test #17:
score: 0
Accepted
time: 1853ms
memory: 4124kb
Test #18:
score: 0
Accepted
time: 1805ms
memory: 4020kb
Test #19:
score: 0
Accepted
time: 297ms
memory: 3728kb
Test #20:
score: 0
Accepted
time: 152ms
memory: 3812kb
Test #21:
score: 0
Accepted
time: 5433ms
memory: 6616kb
Test #22:
score: 0
Accepted
time: 9463ms
memory: 7496kb
Test #23:
score: 0
Accepted
time: 57ms
memory: 3792kb
Test #24:
score: 0
Accepted
time: 153ms
memory: 3784kb
Test #25:
score: 0
Accepted
time: 3292ms
memory: 4372kb
Test #26:
score: 0
Accepted
time: 3316ms
memory: 4384kb
Test #27:
score: 0
Accepted
time: 3373ms
memory: 4440kb
Test #28:
score: 0
Accepted
time: 749ms
memory: 4064kb
Test #29:
score: 0
Accepted
time: 831ms
memory: 4040kb
Test #30:
score: 0
Accepted
time: 807ms
memory: 3980kb
Test #31:
score: 0
Accepted
time: 8496ms
memory: 7336kb
Test #32:
score: 0
Accepted
time: 4486ms
memory: 4660kb
Test #33:
score: 0
Accepted
time: 3978ms
memory: 4652kb
Test #34:
score: 0
Accepted
time: 49ms
memory: 3740kb
Test #35:
score: -100
Wrong Answer
time: 0ms
memory: 3668kb