結果
問題 | No.714 回転寿司屋のシミュレート |
ユーザー |
|
提出日時 | 2018-07-13 23:08:46 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 290 ms / 2,000 ms |
コード長 | 1,271 bytes |
コンパイル時間 | 2,691 ms |
コンパイル使用メモリ | 85,692 KB |
実行使用メモリ | 48,988 KB |
最終ジャッジ日時 | 2024-10-09 05:33:05 |
合計ジャッジ時間 | 11,583 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
import java.io.PrintWriter;import java.util.HashMap;import java.util.HashSet;import java.util.Scanner;class Main {public static void main(String[] args) {new Main().run();}void run() {Scanner sc = new Scanner(System.in);PrintWriter pw = new PrintWriter(System.out);int N = sc.nextInt();HashMap<String, Integer>[] hs = new HashMap[20];for (int i = 0; i < hs.length; ++i) {hs[i] = new HashMap<String, Integer>();}for (int i = 0; i < N; ++i) {int t = sc.nextInt();if (t == 0) {int ni = sc.nextInt() - 1;int mi = sc.nextInt();for (int j = 0; j < mi; ++j) {add(hs[ni], sc.next());}} else if (t == 1) {String s = sc.next();boolean f = false;for (int j = 0; j < 20; ++j) {if (hs[j].containsKey(s)) {pw.println(j + 1);rm(hs[j], s);f = true;break;}}if (!f)pw.println(-1);} else if (t == 2) {hs[sc.nextInt() - 1].clear();}}pw.close();}void add(HashMap<String, Integer> h, String s) {if (h.containsKey(s)) {h.put(s, h.get(s) + 1);} else {h.put(s, 1);}}void rm(HashMap<String, Integer> h, String s) {if (h.get(s) == 1) {h.remove(s);} else {h.put(s, h.get(s) - 1);}}}