Submission #1372686
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];
void dfs(int v,int d,int c){
Edge *e;
if(d<0) return;
if(color[v]==0) color[v]=c;
for(e=edge[v];e!=NULL;e=e->next){
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=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
2017-06-24 16:13:51+0900
Task
B - Splatter Painting
User
trainstation
Language
C (GCC 5.4.1)
Score
0
Code Size
1216 Byte
Status
TLE
Exec Time
2104 ms
Memory
10752 KB
Compile Error
./Main.c: In function ‘main’:
./Main.c:49:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
^
./Main.c:52:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&a,&b);
^
./Main.c:56:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&q);
^
./Main.c:58: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
0 / 200
0 / 500
Status
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
1771 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
TLE
2103 ms
256 KB
10_06.txt
AC
14 ms
128 KB
10_07.txt
AC
1 ms
128 KB
10_08.txt
AC
74 ms
384 KB
10_09.txt
AC
54 ms
384 KB
10_10.txt
AC
53 ms
384 KB
10_11.txt
AC
101 ms
384 KB
10_12.txt
AC
73 ms
384 KB
10_13.txt
AC
3 ms
384 KB
10_14.txt
AC
4 ms
384 KB
10_15.txt
AC
2 ms
256 KB
10_16.txt
TLE
2103 ms
384 KB
10_17.txt
TLE
2103 ms
384 KB
20_01.txt
TLE
2104 ms
8704 KB
20_02.txt
TLE
2104 ms
8704 KB
20_03.txt
TLE
2103 ms
10752 KB
20_04.txt
TLE
2103 ms
2688 KB
20_05.txt
AC
471 ms
256 KB
20_06.txt
AC
9 ms
1536 KB
20_07.txt
AC
104 ms
256 KB
20_08.txt
TLE
2103 ms
1536 KB
20_09.txt
AC
33 ms
256 KB
20_10.txt
TLE
2103 ms
1024 KB
20_11.txt
TLE
2103 ms
1664 KB
20_12.txt
AC
109 ms
7296 KB
20_13.txt
AC
556 ms
8448 KB
20_14.txt
AC
724 ms
8448 KB
20_15.txt
TLE
2104 ms
8704 KB
20_16.txt
TLE
2104 ms
8704 KB