Submission #1413732
Source Code Expand
#include <cstdio>
#include <algorithm>
#define maxn 100000+10
using namespace std;
int f[maxn],ans[maxn],n,m,Q,x,y,z,head[maxn],g;
struct xx
{
int v,next;
}b[maxn<<1];
struct yy
{
int x,d,col;
}a[maxn];
void add(int u,int v)
{
b[++g]=(xx){v,head[u]};
head[u]=g;
}
void dfs(int x,int d,int col)
{
if (f[x]>=d) return ;
f[x]=d;
if (d<=0)return ;
if (!ans[x])ans[x]=col;
for (int i=head[x];i;i=b[i].next)
{
int v=b[i].v;
dfs(v,d-1,col);
}
}
int main()
{
scanf("%d%d",&n,&m);
for (int i=1;i<=m;++i)
scanf("%d%d",&x,&y),add(x,y),add(y,x);
scanf("%d",&Q);
for (int i=1;i<=Q;++i)
scanf("%d%d%d",&x,&y,&z),a[i]=(yy){x,y+1,z};
for (int i=Q;i>=1;--i)
dfs(a[i].x,a[i].d,a[i].col);
for (int i=1;i<=n;++i) printf("%d\n",ans[i]);
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Splatter Painting |
User |
vjudge1 |
Language |
Bash (GNU bash v4.3.11) |
Score |
0 |
Code Size |
762 Byte |
Status |
RE |
Exec Time |
17 ms |
Memory |
1568 KB |
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 |
RE |
17 ms |
1568 KB |
00_example_02.txt |
RE |
3 ms |
568 KB |
10_01.txt |
RE |
3 ms |
572 KB |
10_02.txt |
RE |
3 ms |
572 KB |
10_03.txt |
RE |
3 ms |
568 KB |
10_04.txt |
RE |
3 ms |
568 KB |
10_05.txt |
RE |
3 ms |
568 KB |
10_06.txt |
RE |
3 ms |
572 KB |
10_07.txt |
RE |
3 ms |
572 KB |
10_08.txt |
RE |
3 ms |
568 KB |
10_09.txt |
RE |
3 ms |
572 KB |
10_10.txt |
RE |
3 ms |
568 KB |
10_11.txt |
RE |
3 ms |
568 KB |
10_12.txt |
RE |
3 ms |
572 KB |
10_13.txt |
RE |
3 ms |
568 KB |
10_14.txt |
RE |
3 ms |
568 KB |
10_15.txt |
RE |
3 ms |
572 KB |
10_16.txt |
RE |
3 ms |
572 KB |
10_17.txt |
RE |
3 ms |
572 KB |
20_01.txt |
RE |
3 ms |
572 KB |
20_02.txt |
RE |
3 ms |
568 KB |
20_03.txt |
RE |
3 ms |
572 KB |
20_04.txt |
RE |
3 ms |
572 KB |
20_05.txt |
RE |
3 ms |
572 KB |
20_06.txt |
RE |
3 ms |
572 KB |
20_07.txt |
RE |
3 ms |
572 KB |
20_08.txt |
RE |
3 ms |
572 KB |
20_09.txt |
RE |
3 ms |
568 KB |
20_10.txt |
RE |
3 ms |
572 KB |
20_11.txt |
RE |
3 ms |
572 KB |
20_12.txt |
RE |
3 ms |
572 KB |
20_13.txt |
RE |
3 ms |
568 KB |
20_14.txt |
RE |
3 ms |
572 KB |
20_15.txt |
RE |
3 ms |
568 KB |
20_16.txt |
RE |
3 ms |
568 KB |