QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372166#2432. Go with the FlowWe_Are_ChenoughWA 1ms3764kbC++141.4kb2024-03-31 00:51:012024-03-31 00:51:03

Judging History

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

  • [2024-03-31 00:51:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3764kb
  • [2024-03-31 00:51:01]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

#define endl '\n'

typedef long long ll;

const int mxn = 202505;

int n;
pair<int, int> pos[mxn];
vector<string> wrds;

int line = 0;

int testa(int len){
    int cont = 0, resp = 0;
    for(int i = 0; i<n-1; i++){
        cont+=(int)wrds[i].size();

        if(cont + 1 + (int)wrds[i+1].size()>len){
            cont = 0;
            line++;
            continue;
        }

        cont++;
        
        int atual = 1;
        if(pos[cont].first==line-1){
            atual = pos[cont].second + 1;
        }

        pos[cont] = {line, atual};
        pos[cont-1] = {line, atual};
        pos[cont+1] = {line, atual};
    
        resp=max(resp, atual);
    }
    line+=2;
    return resp;
}

signed main(){
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    cin >> n;

    int maior = 0, soma = 0;

    for(int i=0; i<n; i++){
        string a;
        cin >> a;

        maior = max(maior, int(a.size()));

        soma += int(a.size());

        wrds.push_back(a);
    }

    pair<int, int> ans = {0, 0};

    for(int i=maior; i<soma + n; i++){
        int agr = testa(i);

        if(agr > ans.first){
            ans.first = agr;
            ans.second = i;
        }
    }

    cout << ans.second << ' ' << ans.first << endl;

    return 0;
}

Details

Test #1:

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

Test #2:

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

Test #3:

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

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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