結果

問題 No.1563 Same Degree
ユーザー AsahiAsahi
提出日時 2023-02-04 18:22:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,737 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 75,548 KB
実行使用メモリ 64,936 KB
最終ジャッジ日時 2023-09-16 14:52:35
合計ジャッジ時間 12,318 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,592 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 379 ms
60,036 KB
testcase_12 AC 519 ms
60,072 KB
testcase_13 AC 787 ms
64,548 KB
testcase_14 AC 801 ms
62,932 KB
testcase_15 AC 717 ms
64,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;
import java.util.stream.Stream;

public class Main{
    /* 入出力 */
    static BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static PrintWriter output = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    /* 定数 */
    static final int [] y4 = {0,1,0,-1};
    static final int [] x4 = {1,0,-1,0};
    static final int  INF1 = Integer.MAX_VALUE;
    static final long INF2 = Long.MAX_VALUE;
    static final long MOD1 = (long)1e9+7;
    static final long MOD2 = 998244353;
    /* Main */
    public static void main(String[] args) throws IOException{
        int T = sc.nextInt();
        while(T-->0) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int same = 0;
            int [] degree = new int[n];
            int [] count = new int[n];
            while(m-->0) {
                int u = sc.nextInt();
                int v = sc.nextInt();
                u--;v--;
                if(degree[u] > 0) {
                    count[degree[u]]--;
                    if(count[degree[u]] <= 1) same--;
                }
                if(degree[v] > 0) {
                    count[degree[v]]--;
                    if(count[degree[v]] <= 1) same--;
                }
                degree[u]++;
                degree[v]++;
                count[degree[u]]++;
                count[degree[v]]++;
                if(count[degree[u]] > 1) same++;
                if(count[degree[v]] > 1) same++;
            }
            if(same >= 1) output.println("Yes");
            else output.print("No");
        }
        output.flush();        
    }
}
0