結果

問題 No.479 頂点は要らない
コンテスト
ユーザー fal_rnd
提出日時 2017-01-27 23:23:15
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 830 ms / 1,500 ms
コード長 879 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,426 ms
コンパイル使用メモリ 85,092 KB
実行使用メモリ 64,212 KB
最終ジャッジ日時 2026-05-26 14:59:31
合計ジャッジ時間 17,300 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package yukicodercontest155;

import java.util.*;
public class D{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int n=s.nextInt(),m=s.nextInt();
		BitSet b=new BitSet(n);
		PriorityQueue<Edge> queue = new PriorityQueue<>();
		for(int i=0;i<m;i++) {
			queue.add(new Edge(s.nextInt(), s.nextInt()));
		}
		boolean buf;
		for(int i=n-1;i>=0;i--) {
			buf=b.get(i);
			while((!queue.isEmpty())&&i==queue.peek().t) {
				if(!buf)
					b.set(queue.poll().s);
				else
					queue.poll();
			}
		}
		for(int i=b.previousSetBit(114514);i>=0;i--) {
			System.out.print(b.get(i)?1:0);
		}
		System.out.println();
	}
}
class Edge implements Comparable<Edge>{
	int s,t;
	Edge(int s,int t) {
		this.s=s;
		this.t=t;
	}
	@Override
	public int compareTo(Edge o) {
		return o.t-this.t;
	}
	@Override
	public String toString() {
		return ""+s+" "+t;
	}
}
0