728x90
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
41
42
43
44
|
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) throws IOException{
int N = Integer.parseInt(br.readLine());
StringBuilder sBuilder = new StringBuilder();
String[] fileNames = new String[N];
for(int i=0; i<N; i++) {
fileNames[i] = br.readLine();
}
UpperLoop :
for(int i=0; i<fileNames[0].length(); i++) {
for(int j=0; j<N ;j++) {
if(fileNames[j].charAt(i)!=fileNames[0].charAt(i)) {
sBuilder.append("?");
continue UpperLoop;
}
}
sBuilder.append(fileNames[0].charAt(i));
}
bw.write(sBuilder.toString());
bw.flush();
bw.close();
}
}
|
cs |
'알고리즘 풀이 > 백준' 카테고리의 다른 글
[백준][Java] 1966번 프린터 큐 (Queue, LinkedList) (0) | 2021.09.11 |
---|---|
[백준][Java] 5430번 AC (String, Deque) (0) | 2021.09.09 |
[백준][Java] 4949번 균형잡힌 세상 (String, stack) (0) | 2021.09.08 |
[백준][Java] 11404번 플로이드 (플로이드 와샬, DP) (0) | 2021.09.08 |
[백준][Java] 5430번 AC (0) | 2021.07.17 |