forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.java
More file actions
27 lines (26 loc) · 755 Bytes
/
A.java
File metadata and controls
27 lines (26 loc) · 755 Bytes
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
import java.io.*;
import java.math.*;
import java.util.*;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String[] a = new String[n];
for(int i = 0; i < n; ++i) {
a[i] = sc.next();
}
int res = 0;
for(int i = 0; i < a[0].length(); ++i) {
String cur = a[0].substring(0, i+1);
boolean ok = true;
for(int u = 0; u < n; ++u)
if (!a[u].startsWith(cur)) {
ok = false;
break;
}
if (ok) res = i + 1;
else break;
}
System.out.println(res);
}
}