Solution
2023-07-19 09:57:30
发布于:广东
4阅读
0回复
0点赞
#include <iostream>
using namespace std;
int main() {
int n;
string s;
cin >> n >> s;
for(int guess = 1; guess <= n; guess++) {
bool good = true;
for(int i = 0; i + guess <= n; i++) {
for(int j = 0; j < i; j++) {
if(s.substr(i, guess) == s.substr(j, guess)) {
good = false;
}
}
}
if(good) {
cout << guess << "\n";
break;
}
}
}
这里空空如也
有帮助,赞一个