QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#372146#2432. Go with the FlowWe_Are_Chenough#WA 1ms3824kbC++171.3kb2024-03-30 23:39:472024-03-30 23:39:47

Judging History

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

  • [2024-03-30 23:39:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2024-03-30 23:39:47]
  • 提交

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() + 1;

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

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

        pos[cont] = {line, atual+1};
        pos[cont-1] = {line, atual+1};
        pos[cont+1] = {line, atual+1};
    
        resp=max(resp, atual+1);
    }
    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;
}

詳細信息

Test #1:

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

Test #2:

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

Test #3:

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

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 3536kb