QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372890#2432. Go with the FlowTWTP_TCTF#RE 1890ms4128kbC++171.4kb2024-03-31 20:22:122024-03-31 20:22:12

Judging History

你现在查看的是最新测评结果

  • [2024-03-31 20:22:12]
  • 评测
  • 测评结果:RE
  • 用时:1890ms
  • 内存:4128kb
  • [2024-03-31 20:22:12]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 1e5 + 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;
}

Details

Test #1:

score: 100
Accepted
time: 1ms
memory: 3624kb

Test #2:

score: 0
Accepted
time: 1ms
memory: 3612kb

Test #3:

score: 0
Accepted
time: 0ms
memory: 3652kb

Test #4:

score: 0
Accepted
time: 0ms
memory: 3564kb

Test #5:

score: 0
Accepted
time: 1ms
memory: 3572kb

Test #6:

score: 0
Accepted
time: 0ms
memory: 3676kb

Test #7:

score: 0
Accepted
time: 1ms
memory: 3708kb

Test #8:

score: 0
Accepted
time: 0ms
memory: 3616kb

Test #9:

score: 0
Accepted
time: 1ms
memory: 3612kb

Test #10:

score: 0
Accepted
time: 1ms
memory: 3708kb

Test #11:

score: 0
Accepted
time: 0ms
memory: 3656kb

Test #12:

score: 0
Accepted
time: 1ms
memory: 3720kb

Test #13:

score: 0
Accepted
time: 77ms
memory: 3780kb

Test #14:

score: 0
Accepted
time: 74ms
memory: 3780kb

Test #15:

score: 0
Accepted
time: 78ms
memory: 3676kb

Test #16:

score: 0
Accepted
time: 1890ms
memory: 4104kb

Test #17:

score: 0
Accepted
time: 1838ms
memory: 4128kb

Test #18:

score: 0
Accepted
time: 1815ms
memory: 4076kb

Test #19:

score: 0
Accepted
time: 291ms
memory: 3808kb

Test #20:

score: 0
Accepted
time: 154ms
memory: 3692kb

Test #21:

score: -100
Runtime Error