-
Notifications
You must be signed in to change notification settings - Fork 0
/
1235.cpp
40 lines (35 loc) · 606 Bytes
/
1235.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int>pi;
int n, len;
vector<string>v;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n;
for (int i = 0; i < n; i++)
{
string str; cin >> str;
v.push_back(str);
if(len == 0) len = str.size();
}
map<string, int>m;
for (int k = len - 1; k >= 0; k--)
{
bool flag = 0;
for (int i = 0; i < n; i++)
{
string str = v[i].substr(k);
if (m.find(str) != m.end()) {
flag = 1;
break;
}
m[str]++;
}
if (!flag) {
cout << len - k;
return 0;
}
}
}