Submission #1456585
Source Code Expand
#include<bits/stdc++.h> using namespace std; long long N, M, Q; vector<long long> tree[100005]; long long v[100005]; long long d[100005]; long long c[100005]; long long ans[100005]; set<pair<long long, long long> > done; void paint(long long node, long long dis, long long col){ if(done.count(make_pair(node, dis)) != 0){ return; } done.insert(make_pair(node, dis)); if(ans[node] == 0){ ans[node] = col; } if(dis == 0){ return; } for(long long i = 0; i < tree[node].size(); i++){ paint(tree[node][i], dis - 1, col); } } int main(){ cin >> N >> M; for(long long i = 0; i < M; i++){ long long a, b; cin >> a >> b; a--;b--; tree[a].push_back(b); tree[b].push_back(a); //cin >> a[i] >> b[i]; } cin >> Q; for(long long i = Q-1; i >= 0; i--){ cin >> v[i] >> d[i] >> c[i]; } for(long long i = 0; i < Q; i++){ paint(v[i] - 1, d[i], c[i]); } for(long long i = 0; i < N; i++){ cout << ans[i] << endl; } }
Submission Info
Submission Time | |
---|---|
Task | B - Splatter Painting |
User | motomuman |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1007 Byte |
Status | AC |
Exec Time | 1131 ms |
Memory | 67316 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | 500 / 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 | 2 ms | 3712 KB |
00_example_02.txt | AC | 2 ms | 3712 KB |
10_01.txt | AC | 4 ms | 3712 KB |
10_02.txt | AC | 3 ms | 3712 KB |
10_03.txt | AC | 3 ms | 3712 KB |
10_04.txt | AC | 3 ms | 3712 KB |
10_05.txt | AC | 4 ms | 3712 KB |
10_06.txt | AC | 2 ms | 3712 KB |
10_07.txt | AC | 5 ms | 3712 KB |
10_08.txt | AC | 13 ms | 4480 KB |
10_09.txt | AC | 13 ms | 4608 KB |
10_10.txt | AC | 13 ms | 4480 KB |
10_11.txt | AC | 13 ms | 4608 KB |
10_12.txt | AC | 13 ms | 4608 KB |
10_13.txt | AC | 9 ms | 4096 KB |
10_14.txt | AC | 8 ms | 3968 KB |
10_15.txt | AC | 7 ms | 3840 KB |
10_16.txt | AC | 13 ms | 4992 KB |
10_17.txt | AC | 13 ms | 4992 KB |
20_01.txt | AC | 1125 ms | 55424 KB |
20_02.txt | AC | 1131 ms | 55168 KB |
20_03.txt | AC | 1127 ms | 55296 KB |
20_04.txt | AC | 161 ms | 8448 KB |
20_05.txt | AC | 10 ms | 4096 KB |
20_06.txt | AC | 152 ms | 4992 KB |
20_07.txt | AC | 10 ms | 4224 KB |
20_08.txt | AC | 70 ms | 5248 KB |
20_09.txt | AC | 10 ms | 4224 KB |
20_10.txt | AC | 57 ms | 4992 KB |
20_11.txt | AC | 90 ms | 5632 KB |
20_12.txt | AC | 333 ms | 20608 KB |
20_13.txt | AC | 726 ms | 43008 KB |
20_14.txt | AC | 761 ms | 44672 KB |
20_15.txt | AC | 967 ms | 67188 KB |
20_16.txt | AC | 999 ms | 67316 KB |