-
Notifications
You must be signed in to change notification settings - Fork 2
/
AnsLeak.java
125 lines (109 loc) · 3.11 KB
/
AnsLeak.java
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* package codechef; // don't place package name! */
//https://www.codechef.com/APRIL20B/problems/ANSLEAK/
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class FastReader {
byte[] buf = new byte[2048];
int index, total;
InputStream in;
FastReader(InputStream is) {
in = is;
}
int scan() throws IOException {
if (index >= total) {
index = 0;
total = in.read(buf);
if (total <= 0) {
return -1;
}
}
return buf[index++];
}
String next() throws IOException {
int c;
for (c = scan(); c <= 32; c = scan()) ;
StringBuilder sb = new StringBuilder();
for (; c > 32; c = scan()) {
sb.append((char) c);
}
return sb.toString();
}
String nextLine() throws IOException {
int c;
for (c = scan(); c <= 32; c = scan()) ;
StringBuilder sb = new StringBuilder();
for (; c != 10 && c != 13; c = scan()) {
sb.append((char) c);
}
return sb.toString();
}
char nextChar() throws IOException {
int c;
for (c = scan(); c <= 32; c = scan()) ;
return (char) c;
}
int nextInt() throws IOException {
int c, val = 0;
for (c = scan(); c <= 32; c = scan()) ;
boolean neg = c == '-';
if (c == '-' || c == '+') {
c = scan();
}
for (; c >= '0' && c <= '9'; c = scan()) {
val = (val << 3) + (val << 1) + (c & 15);
}
return neg ? -val : val;
}
long nextLong() throws IOException {
int c;
long val = 0;
for (c = scan(); c <= 32; c = scan()) ;
boolean neg = c == '-';
if (c == '-' || c == '+') {
c = scan();
}
for (; c >= '0' && c <= '9'; c = scan()) {
val = (val << 3) + (val << 1) + (c & 15);
}
return neg ? -val : val;
}
}
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
FastReader sc=new FastReader(System.in);
StringBuilder sb=new StringBuilder();
PrintWriter pw=new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0){
long n=sc.nextLong();
int m=sc.nextInt();
long k=sc.nextLong();
for(int i=0;i<n;i++)
{
int arr[]=new int[m+1];
for(int j=0;j<k;j++)
{
int a=sc.nextInt();
arr[a]++;
}
int max=-1,res=0;
for(int x=1;x<=m;x++)
{
if(max<arr[x]){
res=x;
max=arr[x];
}
}
sb.append(res+" ");
}
sb.append("\n");
}
pw.println(sb);
pw.flush();
}
}