QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#575495#9320. Find the Easiest Problem1091857051WA 219ms66708kbJava82.5kb2024-09-19 14:49:042024-09-19 14:49:04

Judging History

你现在查看的是最新测评结果

  • [2024-09-19 14:49:04]
  • 评测
  • 测评结果:WA
  • 用时:219ms
  • 内存:66708kb
  • [2024-09-19 14:49:04]
  • 提交

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.println(st[i][0]+" "+st[i][1]+" "+st[i][2]);
			}
		}
		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: 31ms
memory: 38580kb

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: 219ms
memory: 66708kb

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
TgBNO H...

result:

wrong answer 1st lines differ - expected: 'Z', found: 'WaiooyIXa O accepted'