Submission #1372684


Source Code Expand

#include <stdio.h>
#include <stdlib.h>
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define INF 1000000000
typedef struct LIST{
	int to;
	struct LIST *next;
}Edge;
Edge** init(int v){
	Edge **edge=(Edge**)calloc(v,sizeof(Edge*));
	return edge;
}
void add_edge(Edge **edge,int s,int t){
	Edge *tmp=(Edge*)malloc(sizeof(Edge));
	tmp->to=t;
	tmp->next=edge[s];
	edge[s]=tmp;
	return;
}
void delete_edge(Edge **edge,int v){
	int i;
	Edge *e,*tmp;
	FOR(i,0,v){
		e=edge[i];
		while(e!=NULL){
			tmp=e->next;
			free(e);
			e=tmp;
		}
	}
	return;
}
Edge **edge;
int color[100000];
int num[100000];
void dfs(int v,int d,int c){
	Edge *e;
	num[v]=d;
	if(color[v]==0) color[v]=c;
	for(e=edge[v];e!=NULL;e=e->next){
		if(num[e->to]<d-1)dfs(e->to,d-1,c);
	}
	return;
}
int v[100000],d[100000],c[100000];
int main(void)
{
	int n,m,q,a,b,i;
	scanf("%d%d",&n,&m);
	edge=init(n);
	FOR(i,0,m){
		scanf("%d%d",&a,&b);
		add_edge(edge,--a,--b);
		add_edge(edge,b,a);
	}
	scanf("%d",&q);
	FOR(i,0,q){
		scanf("%d%d%d",&v[i],&d[i],&c[i]);
		v[i]--;
	}
	FOR(i,0,n) num[i]=-1;
	for(i=q-1;i>=0;i--) dfs(v[i],d[i],c[i]);
	FOR(i,0,n) printf("%d\n",color[i]);
	delete_edge(edge,n);
	return 0;
}
    

Submission Info

Submission Time
Task B - Splatter Painting
User trainstation
Language C (GCC 5.4.1)
Score 700
Code Size 1270 Byte
Status AC
Exec Time 95 ms
Memory 9600 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:50:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ^
./Main.c:53:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&a,&b);
   ^
./Main.c:57:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&q);
  ^
./Main.c:59:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d",&v[i],&d[i],&c[i]);
   ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 500 / 500
Status
AC × 2
AC × 19
AC × 35
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
Subtask1 00_example_01.txt, 00_example_02.txt, 10_01.txt, 10_02.txt, 10_03.txt, 10_04.txt, 10_05.txt, 10_06.txt, 10_07.txt, 10_08.txt, 10_09.txt, 10_10.txt, 10_11.txt, 10_12.txt, 10_13.txt, 10_14.txt, 10_15.txt, 10_16.txt, 10_17.txt
All 00_example_01.txt, 00_example_02.txt, 10_01.txt, 10_02.txt, 10_03.txt, 10_04.txt, 10_05.txt, 10_06.txt, 10_07.txt, 10_08.txt, 10_09.txt, 10_10.txt, 10_11.txt, 10_12.txt, 10_13.txt, 10_14.txt, 10_15.txt, 10_16.txt, 10_17.txt, 20_01.txt, 20_02.txt, 20_03.txt, 20_04.txt, 20_05.txt, 20_06.txt, 20_07.txt, 20_08.txt, 20_09.txt, 20_10.txt, 20_11.txt, 20_12.txt, 20_13.txt, 20_14.txt, 20_15.txt, 20_16.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 1 ms 128 KB
00_example_02.txt AC 1 ms 128 KB
10_01.txt AC 1 ms 256 KB
10_02.txt AC 1 ms 128 KB
10_03.txt AC 1 ms 128 KB
10_04.txt AC 1 ms 128 KB
10_05.txt AC 1 ms 256 KB
10_06.txt AC 1 ms 128 KB
10_07.txt AC 1 ms 256 KB
10_08.txt AC 2 ms 384 KB
10_09.txt AC 2 ms 384 KB
10_10.txt AC 2 ms 384 KB
10_11.txt AC 2 ms 384 KB
10_12.txt AC 2 ms 384 KB
10_13.txt AC 1 ms 384 KB
10_14.txt AC 1 ms 384 KB
10_15.txt AC 1 ms 384 KB
10_16.txt AC 2 ms 384 KB
10_17.txt AC 2 ms 384 KB
20_01.txt AC 95 ms 9600 KB
20_02.txt AC 95 ms 9600 KB
20_03.txt AC 94 ms 9472 KB
20_04.txt AC 23 ms 2816 KB
20_05.txt AC 2 ms 256 KB
20_06.txt AC 10 ms 1920 KB
20_07.txt AC 2 ms 256 KB
20_08.txt AC 74 ms 1536 KB
20_09.txt AC 2 ms 256 KB
20_10.txt AC 19 ms 1152 KB
20_11.txt AC 66 ms 1792 KB
20_12.txt AC 44 ms 7680 KB
20_13.txt AC 72 ms 8832 KB
20_14.txt AC 75 ms 8832 KB
20_15.txt AC 71 ms 9344 KB
20_16.txt AC 72 ms 9472 KB