QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372150 | #2432. Go with the Flow | cciafrino# | AC ✓ | 864ms | 4320kb | C++20 | 1.3kb | 2024-03-30 23:49:01 | 2024-03-30 23:49:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int N; cin >> N;
int max_len = 0;
vector<string> S(N);
for (int i = 0; i < N; ++i) {
cin >> S[i];
max_len = max(max_len, int(S[i].size()));
}
int longest_river = 0, line_id = -1, steps = 1e9;
for (; steps > longest_river; max_len++) {
steps = 0;
vector<int> dp(max_len);
for (int i = 0, j = 0; i < N; i = j+1) {
steps++;
int width = int(S[i].size());
vector<int> ndp(max_len);
j = i;
while (j+1 < N && width + 1 + int(S[j+1].size()) <= max_len) {
ndp[width] = dp[width] + 1;
if (width < max_len-1) {
ndp[width] = max(ndp[width], dp[width +1] + 1);
}
if (width >= 1) {
ndp[width] = max(ndp[width], dp[width-1] + 1);
}
if (ndp[width] > longest_river) {
longest_river = ndp[width];
line_id = max_len;
}
width += 1 + int(S[j+1].size());
j++;
}
dp.swap(ndp);
}
}
cout << line_id << ' ' << longest_river << '\n';
}
Details
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3532kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3580kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 3572kb
Test #6:
score: 0
Accepted
time: 1ms
memory: 3832kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 3520kb
Test #8:
score: 0
Accepted
time: 1ms
memory: 3492kb
Test #9:
score: 0
Accepted
time: 0ms
memory: 3560kb
Test #10:
score: 0
Accepted
time: 0ms
memory: 3572kb
Test #11:
score: 0
Accepted
time: 0ms
memory: 3572kb
Test #12:
score: 0
Accepted
time: 0ms
memory: 3816kb
Test #13:
score: 0
Accepted
time: 3ms
memory: 3696kb
Test #14:
score: 0
Accepted
time: 3ms
memory: 3680kb
Test #15:
score: 0
Accepted
time: 3ms
memory: 3684kb
Test #16:
score: 0
Accepted
time: 35ms
memory: 3868kb
Test #17:
score: 0
Accepted
time: 32ms
memory: 3720kb
Test #18:
score: 0
Accepted
time: 31ms
memory: 3756kb
Test #19:
score: 0
Accepted
time: 0ms
memory: 3632kb
Test #20:
score: 0
Accepted
time: 1ms
memory: 3908kb
Test #21:
score: 0
Accepted
time: 136ms
memory: 4132kb
Test #22:
score: 0
Accepted
time: 4ms
memory: 3908kb
Test #23:
score: 0
Accepted
time: 1ms
memory: 3616kb
Test #24:
score: 0
Accepted
time: 0ms
memory: 3704kb
Test #25:
score: 0
Accepted
time: 94ms
memory: 3904kb
Test #26:
score: 0
Accepted
time: 114ms
memory: 3880kb
Test #27:
score: 0
Accepted
time: 117ms
memory: 3952kb
Test #28:
score: 0
Accepted
time: 24ms
memory: 3728kb
Test #29:
score: 0
Accepted
time: 29ms
memory: 3788kb
Test #30:
score: 0
Accepted
time: 28ms
memory: 3808kb
Test #31:
score: 0
Accepted
time: 264ms
memory: 4264kb
Test #32:
score: 0
Accepted
time: 12ms
memory: 3824kb
Test #33:
score: 0
Accepted
time: 2ms
memory: 3836kb
Test #34:
score: 0
Accepted
time: 1ms
memory: 3564kb
Test #35:
score: 0
Accepted
time: 1ms
memory: 3628kb
Test #36:
score: 0
Accepted
time: 148ms
memory: 3968kb
Test #37:
score: 0
Accepted
time: 273ms
memory: 4272kb
Test #38:
score: 0
Accepted
time: 305ms
memory: 4320kb
Test #39:
score: 0
Accepted
time: 450ms
memory: 4036kb
Test #40:
score: 0
Accepted
time: 535ms
memory: 4044kb
Test #41:
score: 0
Accepted
time: 517ms
memory: 4280kb
Test #42:
score: 0
Accepted
time: 209ms
memory: 4020kb
Test #43:
score: 0
Accepted
time: 283ms
memory: 4044kb
Test #44:
score: 0
Accepted
time: 314ms
memory: 4064kb
Test #45:
score: 0
Accepted
time: 700ms
memory: 4036kb
Test #46:
score: 0
Accepted
time: 634ms
memory: 3976kb
Test #47:
score: 0
Accepted
time: 603ms
memory: 4032kb
Test #48:
score: 0
Accepted
time: 604ms
memory: 4076kb
Test #49:
score: 0
Accepted
time: 623ms
memory: 3972kb
Test #50:
score: 0
Accepted
time: 504ms
memory: 4228kb
Test #51:
score: 0
Accepted
time: 698ms
memory: 4020kb
Test #52:
score: 0
Accepted
time: 663ms
memory: 4028kb
Test #53:
score: 0
Accepted
time: 280ms
memory: 4044kb
Test #54:
score: 0
Accepted
time: 1ms
memory: 3856kb
Test #55:
score: 0
Accepted
time: 25ms
memory: 3972kb
Test #56:
score: 0
Accepted
time: 4ms
memory: 3744kb
Test #57:
score: 0
Accepted
time: 6ms
memory: 3888kb
Test #58:
score: 0
Accepted
time: 9ms
memory: 3920kb
Test #59:
score: 0
Accepted
time: 30ms
memory: 3800kb
Test #60:
score: 0
Accepted
time: 15ms
memory: 3772kb
Test #61:
score: 0
Accepted
time: 1ms
memory: 3652kb
Test #62:
score: 0
Accepted
time: 19ms
memory: 3752kb
Test #63:
score: 0
Accepted
time: 89ms
memory: 4120kb
Test #64:
score: 0
Accepted
time: 67ms
memory: 3684kb
Test #65:
score: 0
Accepted
time: 864ms
memory: 4020kb
Test #66:
score: 0
Accepted
time: 0ms
memory: 3584kb