跳到正文

个人记录

11

linzongyi_520约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
using namespace std;

int n;
int max_long=1;

int main()
{
    cin >> n;
    vector<string> word(n);

    for(int i=0;i<n;i++)
		cin >> word[i];

    vector<int> lzy(n,1);

    for(int i=0;i<n;i++)
	{
        for(int j=i+1;j<n;j++)
		{
            if(word[j].substr(0, word[i].size()) == word[i])
			{
                if(lzy[j] < lzy[i]+1)
				{
                    lzy[j]=lzy[i]+1;
                    max_long=max(max_long,lzy[j]);
                }
            }
        }
    }
    cout << max_long;
    return 0;
}
原文