QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372907#2432. Go with the FlowTWTP_TCTF#WA 9236ms6888kbC++171.4kb2024-03-31 20:37:212024-03-31 20:37:24

Judging History

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

  • [2024-03-31 20:37:24]
  • 评测
  • 测评结果:WA
  • 用时:9236ms
  • 内存:6888kb
  • [2024-03-31 20:37:21]
  • 提交

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;
}


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: 3600kb

Test #2:

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

Test #3:

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

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

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

Test #13:

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

Test #14:

score: 0
Accepted
time: 80ms
memory: 3672kb

Test #15:

score: 0
Accepted
time: 82ms
memory: 3792kb

Test #16:

score: 0
Accepted
time: 1896ms
memory: 4032kb

Test #17:

score: 0
Accepted
time: 1821ms
memory: 4032kb

Test #18:

score: 0
Accepted
time: 1811ms
memory: 4016kb

Test #19:

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

Test #20:

score: 0
Accepted
time: 158ms
memory: 3684kb

Test #21:

score: 0
Accepted
time: 5416ms
memory: 4664kb

Test #22:

score: 0
Accepted
time: 9236ms
memory: 6888kb

Test #23:

score: 0
Accepted
time: 53ms
memory: 3736kb

Test #24:

score: 0
Accepted
time: 159ms
memory: 3812kb

Test #25:

score: 0
Accepted
time: 3310ms
memory: 4460kb

Test #26:

score: 0
Accepted
time: 3287ms
memory: 4448kb

Test #27:

score: 0
Accepted
time: 3354ms
memory: 4380kb

Test #28:

score: 0
Accepted
time: 744ms
memory: 4012kb

Test #29:

score: 0
Accepted
time: 824ms
memory: 4052kb

Test #30:

score: 0
Accepted
time: 799ms
memory: 4020kb

Test #31:

score: 0
Accepted
time: 8407ms
memory: 5396kb

Test #32:

score: 0
Accepted
time: 4418ms
memory: 4652kb

Test #33:

score: 0
Accepted
time: 3910ms
memory: 4668kb

Test #34:

score: 0
Accepted
time: 49ms
memory: 3732kb

Test #35:

score: -100
Wrong Answer
time: 1ms
memory: 3616kb