結果
問題 | No.1610 She Loves Me, She Loves Me Not, ... |
ユーザー | merlin |
提出日時 | 2021-07-21 22:13:38 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,436 bytes |
コンパイル時間 | 3,510 ms |
コンパイル使用メモリ | 76,440 KB |
実行使用メモリ | 57,240 KB |
最終ジャッジ日時 | 2023-09-24 18:05:36 |
合計ジャッジ時間 | 6,750 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 45 ms
47,548 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 148 ms
55,556 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 148 ms
55,312 KB |
testcase_10 | WA | - |
testcase_11 | AC | 151 ms
55,932 KB |
testcase_12 | AC | 149 ms
55,608 KB |
testcase_13 | WA | - |
testcase_14 | AC | 64 ms
49,880 KB |
testcase_15 | AC | 73 ms
50,252 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 63 ms
50,000 KB |
testcase_19 | WA | - |
testcase_20 | AC | 63 ms
49,860 KB |
testcase_21 | WA | - |
testcase_22 | AC | 63 ms
51,264 KB |
testcase_23 | AC | 45 ms
49,768 KB |
testcase_24 | WA | - |
testcase_25 | AC | 45 ms
49,588 KB |
testcase_26 | WA | - |
testcase_27 | AC | 46 ms
49,568 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
ソースコード
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); } }