You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

34 lines
577 B
C++

#include <bits/stdc++.h>
using namespace std;
int main() {
ifstream cin("whereami.in");
ofstream cout("whereami.out");
int N;
cin >> N;
string S;
cin >> S;
for (int K = 1; K <= N; ++K) {
bool good = true;
for (int a = 0; a <= N - K; ++a) {
for (int b = 0; b <= N - K; ++b) {
if (a == b) continue;
bool string_equal = true;
for (int i = 0; i <= K - 1; ++i) {
if (S[a + i] != S[b + i]) string_equal = false;
}
if (string_equal) good = false;
}
}
if (good) {
cout << K;
return 0;
}
}
}