結果
問題 | No.479 頂点は要らない |
ユーザー | zimpha |
提出日時 | 2017-03-31 02:45:13 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 579 ms / 1,500 ms |
コード長 | 2,803 bytes |
コンパイル時間 | 2,228 ms |
コンパイル使用メモリ | 79,464 KB |
実行使用メモリ | 67,840 KB |
最終ジャッジ日時 | 2024-07-07 03:18:35 |
合計ジャッジ時間 | 12,829 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 64 ms
37,328 KB |
testcase_01 | AC | 63 ms
37,884 KB |
testcase_02 | AC | 62 ms
37,552 KB |
testcase_03 | AC | 68 ms
38,012 KB |
testcase_04 | AC | 63 ms
37,576 KB |
testcase_05 | AC | 67 ms
37,952 KB |
testcase_06 | AC | 68 ms
37,636 KB |
testcase_07 | AC | 64 ms
37,208 KB |
testcase_08 | AC | 62 ms
37,904 KB |
testcase_09 | AC | 64 ms
37,672 KB |
testcase_10 | AC | 64 ms
37,880 KB |
testcase_11 | AC | 64 ms
38,100 KB |
testcase_12 | AC | 64 ms
37,800 KB |
testcase_13 | AC | 66 ms
37,536 KB |
testcase_14 | AC | 64 ms
37,968 KB |
testcase_15 | AC | 63 ms
38,088 KB |
testcase_16 | AC | 64 ms
37,860 KB |
testcase_17 | AC | 64 ms
37,988 KB |
testcase_18 | AC | 66 ms
37,688 KB |
testcase_19 | AC | 115 ms
39,604 KB |
testcase_20 | AC | 116 ms
39,452 KB |
testcase_21 | AC | 96 ms
39,192 KB |
testcase_22 | AC | 115 ms
39,616 KB |
testcase_23 | AC | 101 ms
39,236 KB |
testcase_24 | AC | 99 ms
39,004 KB |
testcase_25 | AC | 104 ms
39,624 KB |
testcase_26 | AC | 568 ms
67,840 KB |
testcase_27 | AC | 579 ms
64,712 KB |
testcase_28 | AC | 479 ms
65,760 KB |
testcase_29 | AC | 389 ms
56,076 KB |
testcase_30 | AC | 392 ms
55,932 KB |
testcase_31 | AC | 410 ms
56,192 KB |
testcase_32 | AC | 407 ms
56,256 KB |
testcase_33 | AC | 448 ms
56,364 KB |
testcase_34 | AC | 446 ms
56,064 KB |
testcase_35 | AC | 401 ms
53,932 KB |
testcase_36 | AC | 324 ms
51,172 KB |
testcase_37 | AC | 468 ms
59,544 KB |
testcase_38 | AC | 430 ms
55,328 KB |
testcase_39 | AC | 372 ms
53,584 KB |
testcase_40 | AC | 412 ms
55,616 KB |
ソースコード
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Chiaki.Hoshinomori */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task479 solver = new Task479(); solver.solve(1, in, out); out.close(); } static class Task479 { public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.nextInt(); int m = in.nextInt(); int[] a = new int[m]; int[] b = new int[m]; boolean[] mark = new boolean[m]; ArrayList<Integer>[] edges = new ArrayList[n]; for (int i = 0; i < n; i++) { edges[i] = new ArrayList<>(); } for (int i = 0; i < m; i++) { a[i] = in.nextInt(); b[i] = in.nextInt(); edges[a[i]].add(i); edges[b[i]].add(i); } boolean first = false; for (int i = n - 1; i >= 0; --i) { boolean buy = false; for (int e : edges[i]) { if (mark[e]) continue; if (a[e] + b[e] - i > i) buy = true; } if (buy) { first = true; for (int e : edges[i]) { mark[e] = true; } } if (first) { if (buy) out.printf("1"); else out.printf("0"); } } } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }