結果

問題 No.479 頂点は要らない
ユーザー mono1977mono1977
提出日時 2017-01-27 23:39:51
言語 C90
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 951 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 27,164 KB
実行使用メモリ 812,636 KB
最終ジャッジ日時 2023-08-25 11:04:55
合計ジャッジ時間 4,435 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 0 ms
4,376 KB
testcase_08 AC 0 ms
4,376 KB
testcase_09 AC 0 ms
4,376 KB
testcase_10 AC 0 ms
4,376 KB
testcase_11 AC 0 ms
4,380 KB
testcase_12 AC 0 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 0 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 0 ms
4,380 KB
testcase_19 AC 6 ms
5,756 KB
testcase_20 AC 7 ms
5,684 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 6 ms
5,732 KB
testcase_23 AC 5 ms
5,816 KB
testcase_24 AC 5 ms
5,736 KB
testcase_25 AC 5 ms
5,736 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 MLE -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	int connect[n][n];
	int bit[n];
	int i,j,k;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			connect[i][j]=0;
		}
		bit[i]=0;
	}
	
	int a,b;
	for(i=0;i<m;i++){
		scanf("%d %d",&a,&b);
		connect[a][b]=1;
		connect[b][a]=1;
	}
	
	for(i=n-1;i>=0;i--){//価値の高い頂点から調査
		for(j=0;j<n;j++){
			if(connect[i][j]==1){//辺があったら…
				connect[i][j]=2;
				bit[j]=1;//伸びた辺の反対側の頂点を買収
				for(k=0;k<n;k++){
					connect[j][k]=0;//反対側の頂点から伸びた辺もこのとき買収できる
					connect[k][j]=0;
				}
			}
		}
	}
	
	int leadZeroEnd = 0;
	for(i=n-1;i>=0;i--){
		if(bit[i]==0 && leadZeroEnd==0){
			continue;
		}
		if(bit[i]==1){
			leadZeroEnd=1;
		}
		printf("%d",bit[i]);
	}puts("");
	
    return 0;
}
0