結果
問題 | No.1563 Same Degree |
ユーザー | irumo8202 |
提出日時 | 2022-02-18 07:57:13 |
言語 | TypeScript (5.4.3) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,394 bytes |
コンパイル時間 | 7,005 ms |
コンパイル使用メモリ | 258,120 KB |
実行使用メモリ | 51,456 KB |
最終ジャッジ日時 | 2023-09-11 18:03:38 |
合計ジャッジ時間 | 11,972 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 76 ms
51,456 KB |
testcase_01 | TLE | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
ソースコード
import * as fs from "fs" const defaultdict = <K>(defaultValue: number) => { const dict: Map<K, number> = new Map() const get = (key: K): number => { return dict.has(key) ? dict.get(key) : defaultValue } const set = (key: K, value: number): void => { dict.set(key, value) } const add = (key: K, value: number): void => { dict.has(key) ? set(key, get(key) + value) : set(key, value) } const del = (key: K): boolean => { return dict.delete(key) } return { get, add, set, del } } const range = (start: number) => (stop: number) => { return Array.from(Array(stop - start), (_, k) => k + start) } const existsSameValue = <T>(arr: T[]): boolean => { const g: Set<T> = new Set(arr) return g.size !== arr.length } const main = (args: string): void => { const input = args.trim().split("\n"); const T = parseInt(input.shift()) for (let i = 0; i < T; i++) { const [N, M] = input.shift().split(" ").map(x => Number(x)) const G = defaultdict(0) for (let j = 0; j < M; j++) { const [u, v] = input.shift().split(" ").map(x => Number(x)) G.add(u, 1) G.add(v, 1) } const degree = range(1)(N + 1).map(x => G.get(x)) console.log(existsSameValue(degree) ? "Yes" : "No") } } main(fs.readFileSync('/dev/stdin', 'utf8'));