Submission #1195313
Source Code Expand
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;
int n, m, q;
vector<int> G[100010];
int v[100010], d[100010], c[100010];
int color[100010];
bool f[100010];
void dfs(int now, int dist, int cl, int pre){
if(dist < 0) return;
if(f[now]) return;
f[now] = true;
color[now] = cl;
rep(i, 0, G[now].size()){
int next = G[now][i];
if(next == pre) continue;
dfs(next, dist - 1, cl, now);
}
}
signed main(){
cin >> n >> m;
memset(color, 0, sizeof(color));
assert(n <= 2000 && m <= 2000 && q <= 2000);
rep(i, 0, m){
int a, b;
cin >> a >> b;
a--; b--;
G[a]. push_back(b);
G[b]. push_back(a);
}
cin >> q;
rep(i, 0, q){
cin >> v[i] >> d[i] >> c[i];
v[i]--;
memset(f, 0, sizeof(f));
dfs(v[i], d[i], c[i], -1);
}
rep(i, 0, n){
cout << color[i] << endl;
}
}
Submission Info
Submission Time |
|
Task |
B - Splatter Painting |
User |
treeone |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1204 Byte |
Status |
RE |
Exec Time |
368 ms |
Memory |
5632 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 |
AC |
3 ms |
4608 KB |
00_example_02.txt |
AC |
3 ms |
4608 KB |
10_01.txt |
WA |
4 ms |
4736 KB |
10_02.txt |
AC |
3 ms |
4608 KB |
10_03.txt |
AC |
3 ms |
4608 KB |
10_04.txt |
AC |
3 ms |
4608 KB |
10_05.txt |
WA |
4 ms |
4736 KB |
10_06.txt |
AC |
3 ms |
4608 KB |
10_07.txt |
AC |
5 ms |
4608 KB |
10_08.txt |
WA |
18 ms |
4736 KB |
10_09.txt |
WA |
17 ms |
4736 KB |
10_10.txt |
WA |
18 ms |
4736 KB |
10_11.txt |
WA |
18 ms |
4736 KB |
10_12.txt |
WA |
18 ms |
4736 KB |
10_13.txt |
AC |
8 ms |
4736 KB |
10_14.txt |
AC |
7 ms |
4736 KB |
10_15.txt |
AC |
7 ms |
4736 KB |
10_16.txt |
AC |
40 ms |
4736 KB |
10_17.txt |
AC |
40 ms |
4736 KB |
20_01.txt |
RE |
198 ms |
4608 KB |
20_02.txt |
RE |
98 ms |
4608 KB |
20_03.txt |
RE |
99 ms |
4608 KB |
20_04.txt |
RE |
98 ms |
4608 KB |
20_05.txt |
WA |
30 ms |
4736 KB |
20_06.txt |
RE |
98 ms |
4608 KB |
20_07.txt |
WA |
31 ms |
4736 KB |
20_08.txt |
RE |
99 ms |
4608 KB |
20_09.txt |
WA |
26 ms |
4736 KB |
20_10.txt |
WA |
368 ms |
5632 KB |
20_11.txt |
RE |
99 ms |
4608 KB |
20_12.txt |
RE |
99 ms |
4608 KB |
20_13.txt |
RE |
99 ms |
4608 KB |
20_14.txt |
RE |
98 ms |
4608 KB |
20_15.txt |
RE |
99 ms |
4608 KB |
20_16.txt |
RE |
99 ms |
4608 KB |