結果
| 問題 | No.1610 She Loves Me, She Loves Me Not, ... | 
| コンテスト | |
| ユーザー |  merlin | 
| 提出日時 | 2021-07-21 22:13:38 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,436 bytes | 
| コンパイル時間 | 3,432 ms | 
| コンパイル使用メモリ | 80,688 KB | 
| 実行使用メモリ | 55,128 KB | 
| 最終ジャッジ日時 | 2024-07-17 18:58:15 | 
| 合計ジャッジ時間 | 7,124 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 2 | 
| other | AC * 11 WA * 21 | 
ソースコード
import java.io.*;
import java.util.*;
class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]);
        ArrayList<Integer> g[]=new ArrayList[n];
        int i,c[]=new int[n];
        for(i=0;i<n;i++) g[i]=new ArrayList<>();
        for(i=0;i<m;i++)
        {
            s=bu.readLine().split(" ");
            int u=Integer.parseInt(s[0])-1,v=Integer.parseInt(s[1])-1;
            g[u].add(v); g[v].add(u);
            c[u]++; c[v]++;
        }
        int ans=0;
        PriorityQueue<int[]> pq=new PriorityQueue<>(new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                if(o1[1]>o2[1]) return 1;
                else return -1;
            }});
        for(i=0;i<n;i++) pq.add(new int[]{i,c[i]});
        while(!pq.isEmpty())
        {
            int a[]=pq.poll();
            if(c[a[0]]==0 || c[a[0]]<a[1]) continue;
            ans++;
            c[a[0]]=0;
            for(int x:g[a[0]])
            {
                c[x]--;
                if(c[x]>0) pq.add(new int[]{x,c[x]});
            }
        }
        //if(ans%2==0) sb.append("No");
        sb.append("Yes");
        System.out.println(sb);
    }
}
            
            
            
        