QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#574253#9320. Find the Easiest ProblemdaringWA 212ms75488kbJava112.7kb2024-09-18 21:13:242024-09-18 21:13:25

Judging History

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

  • [2024-09-18 21:13:25]
  • 评测
  • 测评结果:WA
  • 用时:212ms
  • 内存:75488kb
  • [2024-09-18 21:13:24]
  • 提交

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);
                    map.put(b,new HashSet<>());
                    map.get(b).add(a);
                }
            }
        }
        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: 45ms
memory: 52336kb

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: 212ms
memory: 75488kb

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'