結果
問題 | No.1563 Same Degree |
ユーザー | tenten |
提出日時 | 2021-06-28 14:58:43 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 293 ms / 2,000 ms |
コード長 | 1,503 bytes |
コンパイル時間 | 2,358 ms |
コンパイル使用メモリ | 74,276 KB |
実行使用メモリ | 60,060 KB |
最終ジャッジ日時 | 2023-09-07 18:24:44 |
合計ジャッジ時間 | 6,499 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
49,568 KB |
testcase_01 | AC | 260 ms
58,776 KB |
testcase_02 | AC | 197 ms
55,300 KB |
testcase_03 | AC | 257 ms
58,620 KB |
testcase_04 | AC | 203 ms
55,228 KB |
testcase_05 | AC | 201 ms
55,348 KB |
testcase_06 | AC | 210 ms
58,640 KB |
testcase_07 | AC | 189 ms
57,684 KB |
testcase_08 | AC | 221 ms
58,568 KB |
testcase_09 | AC | 192 ms
58,528 KB |
testcase_10 | AC | 211 ms
58,560 KB |
testcase_11 | AC | 152 ms
55,588 KB |
testcase_12 | AC | 192 ms
55,400 KB |
testcase_13 | AC | 276 ms
57,672 KB |
testcase_14 | AC | 293 ms
60,060 KB |
testcase_15 | AC | 250 ms
56,412 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int t = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < t; i++) { int n = sc.nextInt(); int m = sc.nextInt(); int[] counts = new int[n]; for (int j = 0; j < m; j++) { counts[sc.nextInt() - 1]++; counts[sc.nextInt() - 1]++; } Arrays.sort(counts); boolean exist = false; for (int j = 0; j < n - 1 && !exist; j++) { exist = (counts[j] == counts[j + 1]); } if (exist) { sb.append("Yes"); } else { sb.append("No"); } sb.append("\n"); } System.out.print(sb); } } 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(); } }