-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMentoring.java
More file actions
41 lines (38 loc) · 1.13 KB
/
Copy pathMentoring.java
File metadata and controls
41 lines (38 loc) · 1.13 KB
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
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Mentoring {
public int solution(int n, int m, Integer[][] arr){
int answer = 0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
boolean flog = true;
for (int k=0; k<m;k++){
List<Integer> list = Arrays.asList(arr[k]);
if (list.indexOf(i+1) >= list.indexOf(j+1)){
flog = false;
break;
}
}
if(flog){
answer++;
}
}
}
return answer;
}
public static void main(String[] args) {
Mentoring t = new Mentoring();
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
Integer[][] arr = new Integer[m][n];
for (int i=0;i<m;i++){
for (int j=0;j<n;j++){
arr[i][j] = scanner.nextInt();
}
}
System.out.println(t.solution(n, m, arr));
}
}