結果

問題 No.714 回転寿司屋のシミュレート
ユーザー 37zigen37zigen
提出日時 2018-07-13 23:08:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 292 ms / 2,000 ms
コード長 1,271 bytes
コンパイル時間 2,537 ms
コンパイル使用メモリ 80,344 KB
実行使用メモリ 58,732 KB
最終ジャッジ日時 2024-04-17 11:27:18
合計ジャッジ時間 10,644 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
54,308 KB
testcase_01 AC 145 ms
54,452 KB
testcase_02 AC 175 ms
54,500 KB
testcase_03 AC 178 ms
54,380 KB
testcase_04 AC 199 ms
54,652 KB
testcase_05 AC 217 ms
57,424 KB
testcase_06 AC 241 ms
57,908 KB
testcase_07 AC 258 ms
58,220 KB
testcase_08 AC 292 ms
58,732 KB
testcase_09 AC 247 ms
58,080 KB
testcase_10 AC 239 ms
57,764 KB
testcase_11 AC 228 ms
57,364 KB
testcase_12 AC 237 ms
57,556 KB
testcase_13 AC 217 ms
57,124 KB
testcase_14 AC 231 ms
57,624 KB
testcase_15 AC 227 ms
57,616 KB
testcase_16 AC 226 ms
57,700 KB
testcase_17 AC 237 ms
57,832 KB
testcase_18 AC 233 ms
57,468 KB
testcase_19 AC 229 ms
57,552 KB
testcase_20 AC 231 ms
57,508 KB
testcase_21 AC 233 ms
57,540 KB
testcase_22 AC 222 ms
57,356 KB
testcase_23 AC 221 ms
57,300 KB
testcase_24 AC 219 ms
57,492 KB
testcase_25 AC 225 ms
57,504 KB
testcase_26 AC 220 ms
57,348 KB
testcase_27 AC 220 ms
57,284 KB
testcase_28 AC 212 ms
57,068 KB
testcase_29 AC 218 ms
57,344 KB
testcase_30 AC 136 ms
54,044 KB
testcase_31 AC 143 ms
54,144 KB
testcase_32 AC 142 ms
54,328 KB
testcase_33 AC 137 ms
53,996 KB
testcase_34 AC 136 ms
54,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

}
0