QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#574165 | #9320. Find the Easiest Problem | daring | WA | 215ms | 75024kb | Java11 | 2.6kb | 2024-09-18 20:58:37 | 2024-09-18 20:58:43 |
Judging History
answer
import java.io.*;
import java.util.*;
public class Main {
private static void solve() {
int n=sc.nextInt();
Map<String,Set<String>>map=new HashMap<>();
while (n-->0){
String a=sc.next();
String b=sc.next();
String c=sc.next();
if(c.charAt(0)=='a'){
if(map.get(b)!=null){
map.get(b).add(a);
}else {
Set<String> set = new HashSet<>();
set.add(a);
map.put(b,set);
}
}
}
int mx=0;
String s="";
for (Map.Entry<String, Set<String>> setEntry : map.entrySet()) {
if(setEntry.getValue().size()>mx){
mx= setEntry.getValue().size();
s=setEntry.getKey();
}
}
out.println(s);
}
public static void main(String[] args) {
int T = sc.nextInt();
while (T-- > 0) {
solve();
}
out.flush();
out.close();
}
static Kattio sc = new Kattio();
static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
static class Kattio {
static BufferedReader r;
static StringTokenizer st;
public Kattio() {
r = new BufferedReader(new InputStreamReader(System.in));
}
public String next() {
try {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(r.readLine());
}
return st.nextToken();
} catch (Exception e) {
return null;
}
}
public int nextInt() {
char[] str = next().toCharArray();
int i = 0;
boolean neg = false;
if (str[0] == '-') {
i = 1;
neg = true;
}
int ans = 0;
for (; i < str.length; i++) ans = ans * 10 + (str[i] - '0');
return neg ? -ans : ans;
}
public long nextLong() {
char[] str = next().toCharArray();
int i = 0;
boolean neg = false;
if (str[0] == '-') {
i = 1;
neg = true;
}
long ans = 0;
for (; i < str.length; i++) ans = ans * 10 + (str[i] - '0');
return neg ? -ans : ans;
}
public double nextDouble() {
return Double.parseDouble(next());
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 56ms
memory: 52432kb
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: 215ms
memory: 75024kb
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:
Z P Z I B I G H S K J I H R Z C K O Q P A B I A A N A B Q O F O R T H G K E S D F D R C U V W P A O P E A B U M C T L G V A Z N E O Q F B G J I E M A A S A K W J S E W Z K F I S P M Q G G H W I P T D O A F N C S Y Z S G J F Q F O C B B U C I A E I P K C R X V D N L Q L I X I H U J Z D K G F T F B R ...
result:
wrong answer 2nd lines differ - expected: 'E', found: 'P'