QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#575491#9320. Find the Easiest Problem1091857051WA 216ms66020kbJava82.4kb2024-09-19 14:46:222024-09-19 14:46:23

Judging History

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

  • [2024-09-19 14:46:23]
  • 评测
  • 测评结果:WA
  • 用时:216ms
  • 内存:66020kb
  • [2024-09-19 14:46:22]
  • 提交

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) {
			System.out.println(map.get("P"));
			System.out.println(map.get("Z"));
		}
		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: 44ms
memory: 37192kb

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: 216ms
memory: 66020kb

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:

[0, 1, 6, 7, 8]
[0, 3, 6, 7]
[1, 6]
[2, 7]
[9]
[1, 3]
[1, 2]
null
[7]
[3, 4, 6]
[3]
null
P
E
C
H
A
I
N
F
E
K
H
I
F
B
X
L
R
O
A
H
J
F
I
H
A
A
A
Q
V
T
K
A
F
A
H
G
L
E
S
D
G
D
Q
Y
J
V
H
C
C
O
J
V
T
B
U
E
I
T
C
O
V
H
Z
I
G
O
N
F
O
G
I
B
E
A
D
J
L
A
K
B
J
S
U
V
Z
A
K
A
S
P
D
H
G
J
H
W
I
I
E
G
H
A
F
L
D
V...

result:

wrong answer 1st lines differ - expected: 'Z', found: '[0, 1, 6, 7, 8]'