結果

問題 No.1679 マスゲーム
ユーザー tentententen
提出日時 2021-09-13 18:00:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 691 ms / 2,000 ms
コード長 1,385 bytes
コンパイル時間 2,270 ms
コンパイル使用メモリ 75,160 KB
実行使用メモリ 72,452 KB
最終ジャッジ日時 2023-09-08 01:33:57
合計ジャッジ時間 15,793 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,224 KB
testcase_01 AC 43 ms
49,316 KB
testcase_02 AC 40 ms
49,688 KB
testcase_03 AC 615 ms
67,532 KB
testcase_04 AC 560 ms
68,964 KB
testcase_05 AC 588 ms
69,500 KB
testcase_06 AC 542 ms
70,908 KB
testcase_07 AC 576 ms
71,680 KB
testcase_08 AC 627 ms
69,324 KB
testcase_09 AC 614 ms
70,988 KB
testcase_10 AC 628 ms
70,068 KB
testcase_11 AC 619 ms
70,028 KB
testcase_12 AC 176 ms
55,468 KB
testcase_13 AC 337 ms
63,532 KB
testcase_14 AC 691 ms
72,452 KB
testcase_15 AC 554 ms
67,372 KB
testcase_16 AC 502 ms
65,700 KB
testcase_17 AC 42 ms
49,528 KB
testcase_18 AC 423 ms
59,964 KB
testcase_19 AC 62 ms
50,540 KB
testcase_20 AC 58 ms
50,816 KB
testcase_21 AC 86 ms
51,596 KB
testcase_22 AC 69 ms
50,324 KB
testcase_23 AC 48 ms
49,596 KB
testcase_24 AC 61 ms
50,564 KB
testcase_25 AC 67 ms
50,636 KB
testcase_26 AC 59 ms
50,592 KB
testcase_27 AC 78 ms
50,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        HashMap<Integer, Long> xMap = new HashMap<>();
        HashMap<Integer, Long> yMap = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int type = sc.nextInt();
            int value = sc.nextInt() - sc.nextInt();
            if (type == 0) {
                xMap.put(value, xMap.getOrDefault(value, 0L) + 1);
            } else {
                yMap.put(value, yMap.getOrDefault(value, 0L) + 1);
            }
        }
        long ans = 0;
        for (int x : xMap.keySet()) {
            ans += xMap.get(x) * yMap.getOrDefault(x, 0L);
        }
        System.out.println(ans);
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0