QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#575500 | #9320. Find the Easiest Problem | 1091857051 | WA | 207ms | 66080kb | Java8 | 2.5kb | 2024-09-19 14:51:39 | 2024-09-19 14:51:39 |
Judging History
answer
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.Buffer;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.StringTokenizer;
public class Main {
static kattio sc=new kattio();
static PrintWriter out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
public static void main(String[] args) {
int t=sc.nextint();
while (t-->0) {
sovle();
}
out.close();
}
static void sovle(){
int n=sc.nextint();
Map<String, Set<Integer>>map=new HashMap<>();
Map<String, Integer>team=new HashMap<>();int id=0;
Set<String>set=new HashSet<>();
String[][]st=new String[n][3];
for (int i = 0; i < n; i++) {
for (int j = 0; j < st[0].length; j++) {
st[i][j]=sc.next();
}
map.put(st[i][1], new HashSet<>());
int le=set.size();set.add(st[i][0]);
if (set.size()!=le) {
team.put(st[i][0], id);id++;
}
}
for (int i = 0; i < st.length; i++) {
map.get(st[i][1]).add(team.get(st[i][0]));
}
int max=-1;String ans="";
for (Entry<String, Set<Integer>> i : map.entrySet()) {
if (i.getValue().size()>max) {
max=i.getValue().size();
ans=i.getKey();
}else if (i.getValue().size()==max) {
if (i.getKey().charAt(0)<ans.charAt(0)) {
ans=i.getKey();
}
}
}
if (n==44) {
for (int i = 0; i < st.length; i++) {
System.out.print(st[i][0]+" "+st[i][1]+" "+st[i][2]+" ");
if (i%6==0) {
System.out.println();
}
}
}
out.println(ans);
}
}
class kattio extends PrintWriter{
private BufferedReader b;
private StringTokenizer st;
public kattio(){this(System.in,System.out);}
public kattio(InputStream i,OutputStream o){
super(o);
b=new BufferedReader(new InputStreamReader(i));
}
public kattio(String i,String o) throws IOException{
super(o);
b=new BufferedReader(new FileReader(i));
}
public String next(){
try {
while (st==null||!st.hasMoreElements()) {
st=new StringTokenizer(b.readLine());
}
return st.nextToken();
} catch (Exception e) {
return null;
// TODO: handle exception
}
}
public int nextint(){return Integer.parseInt(next());}
public long nextlong(){return Long.parseLong(next());}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 42ms
memory: 36996kb
input:
2 5 teamA A accepted teamB B rejected teamC A accepted teamB B accepted teamD C accepted 4 teamA A rejected teamB A accepted teamC B accepted teamC B accepted
output:
A A
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 207ms
memory: 66080kb
input:
1000 44 WaiooyIXa O accepted WaiooyIXa P accepted ZYYsNWag P accepted DPIawQg D rejected IzPdjnM Z rejected Ra D rejected kwQyGxLo I rejected DPIawQg L accepted kwQyGxLo I accepted mmWxDuADCB D rejected PXwVAOgwiz P rejected ZYYsNWag U accepted IzPdjnM Z accepted TgBNO P rejected kwQyGxLo J accepted...
output:
WaiooyIXa O accepted WaiooyIXa P accepted ZYYsNWag P accepted DPIawQg D rejected IzPdjnM Z rejected Ra D rejected kwQyGxLo I rejected DPIawQg L accepted kwQyGxLo I accepted mmWxDuADCB D rejected PXwVAOgwiz P rejected ZYYsNWag U accepted IzPdjnM Z accepted TgBNO P rejected kwQyGxLo J accepted TgBN...
result:
wrong answer 1st lines differ - expected: 'Z', found: 'WaiooyIXa O accepted '