5 条题解

  • 0
    @ 2024-1-6 22:15:13

    歪解 哈希表加快读

    import java.util.*;
    import java.io.*;
    public class Main {
    	static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    	static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        public static void main(String[] args) throws Exception{ 
        	int n = Int();
        	HashMap<Integer,Integer> hm = new HashMap<>();
        	for(int i = 1; i<= n;i++) {
        		hm.put(Int(),i);
        	}
        	int t = Int();
        	for(int i = 1; i<= t;i++) {
        		pw.print(hm.getOrDefault(Int(), -1)+" ");
        	}
        	pw.flush();
        }
        public static int Int() throws Exception{
        	st.nextToken();
        	return (int)(st.nval);
        }
        }
    

    信息

    ID
    576
    时间
    1000ms
    内存
    64MiB
    难度
    8
    标签
    (无)
    递交数
    74
    已通过
    12
    上传者