Submit Info #66576

Problem Lang User Status Time Memory
Associative Array java forgetUserName AC 1959 ms 134.41 MiB

ケース詳細
Name Status Time Memory
2_powers_00 AC 1959 ms 134.41 MiB
example_00 AC 55 ms 8.86 MiB
many_0set_00 AC 1891 ms 120.87 MiB
many_0set_sparse_00 AC 814 ms 83.67 MiB
max_random_00 AC 1862 ms 121.19 MiB
max_random_01 AC 1877 ms 122.76 MiB
max_random_02 AC 1887 ms 124.13 MiB
random_00 AC 1026 ms 102.09 MiB
random_01 AC 1066 ms 102.71 MiB
random_02 AC 1195 ms 110.05 MiB
sparse_keys_00 AC 847 ms 85.04 MiB
sparse_keys_01 AC 900 ms 86.57 MiB
unordered_map_killer_00 AC 1745 ms 134.20 MiB
unordered_map_killer_01 AC 1662 ms 130.00 MiB
unordered_map_killer_02 AC 1674 ms 132.34 MiB

import java.util.*; import java.io.*; //https://old.yosupo.jp/problem/associative_array public class Main { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; public static void main(String[] args) throws IOException{ HashMap<Long, Long> _map = new HashMap<>(); int N = readInteger(); for(int i = 0; i < N; i++) { int cmd = readInteger(); if(cmd == 0) { long k = readLong(); long v = readLong(); _map.put(k,v); } else { long k = readLong(); if(_map.containsKey(k)) { System.out.println(_map.get(k)); } else { System.out.println(0); } } } } public static String next() throws IOException{ if(st == null || !st.hasMoreTokens()) { st = new StringTokenizer(br.readLine().trim()); } return st.nextToken(); } public static int readInteger() throws IOException { return Integer.parseInt(next()); } public static long readLong() throws IOException { return Long.parseLong(next()); } }