結果
| 問題 |
No.479 頂点は要らない
|
| ユーザー |
|
| 提出日時 | 2017-01-27 23:17:27 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 1,500 ms |
| コード長 | 540 bytes |
| コンパイル時間 | 110 ms |
| コンパイル使用メモリ | 22,144 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 16:59:22 |
| 合計ジャッジ時間 | 2,033 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:17:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%ld %ld",&n,&m);
| ^~~~~~~~~~~~~~~~~~~~~~
main.c:19:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%ld %ld",&e[i].v[0],&e[i].v[1]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<stdlib.h>
typedef struct{
long v[2];
} edge;
edge e[100000];
int v[100000];
int cmp(const void *a,const void *b){
return ((edge*)b)->v[1]-((edge*)a)->v[1];
}
int main(){
long n,m,i,max=0;
scanf("%ld %ld",&n,&m);
for(i=0;i<m;i++){
scanf("%ld %ld",&e[i].v[0],&e[i].v[1]);
}
qsort(e,m,sizeof(edge),cmp);
for(i=0;i<m;i++){
if(v[e[i].v[0]]==1 || v[e[i].v[1]]==1) continue;
v[e[i].v[0]]=1;
if(e[i].v[0]>max) max=e[i].v[0];
}
for(i=max;i>=0;i--){
printf("%d",v[i]);
}
printf("\n");
return 0;
}