QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#372153#2432. Go with the FlowWe_Are_Chenough#WA 0ms3616kbC++171.8kb2024-03-30 23:56:532024-03-30 23:56:53

Judging History

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

  • [2024-03-30 23:56:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-03-30 23:56:53]
  • 提交

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){
            
            if(cont==len-1){
                cont++;
                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);
            }

            cont = 0;
            line++;
            continue;
        }

        cont++;
        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: 0ms
memory: 3580kb

Test #2:

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

Test #3:

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