QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#574249#9320. Find the Easiest ProblemdaringCompile Error//C++112.7kb2024-09-18 21:12:502024-09-18 21:12:50

Judging History

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

  • [2024-09-18 21:12:50]
  • 评测
  • [2024-09-18 21:12:50]
  • 提交

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());
        }
    }
}

詳細信息

answer.code:1:1: error: ‘import’ does not name a type
    1 | import java.io.*;
      | ^~~~~~
answer.code:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:3:1: error: ‘import’ does not name a type
    3 | import java.util.*;
      | ^~~~~~
answer.code:3:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:6:1: error: expected unqualified-id before ‘public’
    6 | public class Main {
      | ^~~~~~