java两层hashmap,20分后面四个wa
查看原帖
java两层hashmap,20分后面四个wa
445109
mochuen楼主2022/1/23 17:00
import java.io.BufferedInputStream;

import java.io.IOException;

import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;








public class Main {
	
	static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
	static Scanner scanner = new Scanner(new BufferedInputStream(System.in));
	static int n,m,op;
//	static HashMap<Integer, Integer> map1=new HashMap<>();
	static HashMap<Integer,Node> map = new HashMap<>();
	public static void main(String[] args) throws IOException {
		n=scanner.nextInt();
		m=scanner.nextInt();
		while(m--!=0) {
			op=scanner.nextInt();
			if(op==1) {
				int a=scanner.nextInt(),
						b=scanner.nextInt(),
						c=scanner.nextInt();
				map.put(a, new Node(b, c));
			}else if(op==2) {
				int d=scanner.nextInt(),
						e=scanner.nextInt();
				out.println(map.get(d).getMap().get(e));
			}
		}
		out.flush();
		
	}
	static class Node{
		HashMap<Integer, Integer> map = new HashMap<>();
		public Node(int a,int b) {
			// TODO Auto-generated constructor stub
			map.put(a, b);
		}
		public HashMap<Integer, Integer> getMap() {
			return map;
		}
		
	}
	
	

	
	

	
}
	
	
	
	
	
	



	


	
	

	
	
2022/1/23 17:00
加载中...