Submission #2099673
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(int i = (l) ; i < (r); i++)
#define incII(i, l, r) for(int i = (l) ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r) ; i >= (l); i--)
#define inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) < (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define FOR(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)
template<typename T> bool setmin(T & a, T b) { if(b < a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax(T & a, T b) { if(b > a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
// ---- ----
const int M = 100000;
int n, m, q, v[M], d[M], c[M];
vector<int> g[M];
pair<int, int> ans[M];
int main() {
cin >> n >> m;
inc(i, m) {
int a, b;
cin >> a >> b;
a--; b--;
g[a].PB(b);
g[b].PB(a);
}
cin >> q;
inc(i, q) { cin >> v[i] >> d[i] >> c[i]; v[i]--; }
inc(i, n) { ans[i] = MP(-1, -1); }
dec(i, q) {
queue<pair<int, int>> que;
que.emplace(v[i], d[i]);
while(! que.empty()) {
auto p = que.front(); que.pop();
if(p.SE < 0) { continue; }
if(i <= ans[p.FI].FI && p.SE <= ans[p.FI].SE) { continue; }
setmax(ans[p.FI].FI, i);
setmax(ans[p.FI].SE, p.SE);
for(auto && e: g[p.FI]) { que.emplace(e, p.SE - 1); }
}
}
inc(i, n) { cout << (ans[i].FI == -1 ? 0 : c[ans[i].FI]) << "\n"; }
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Splatter Painting |
User |
FF256grhy |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
2338 Byte |
Status |
AC |
Exec Time |
198 ms |
Memory |
8952 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 |
3584 KB |
00_example_02.txt |
AC |
2 ms |
3584 KB |
10_01.txt |
AC |
3 ms |
3584 KB |
10_02.txt |
AC |
2 ms |
3584 KB |
10_03.txt |
AC |
2 ms |
3584 KB |
10_04.txt |
AC |
2 ms |
3584 KB |
10_05.txt |
AC |
3 ms |
3584 KB |
10_06.txt |
AC |
2 ms |
3584 KB |
10_07.txt |
AC |
2 ms |
3584 KB |
10_08.txt |
AC |
5 ms |
3584 KB |
10_09.txt |
AC |
5 ms |
3584 KB |
10_10.txt |
AC |
5 ms |
3584 KB |
10_11.txt |
AC |
5 ms |
3584 KB |
10_12.txt |
AC |
5 ms |
3584 KB |
10_13.txt |
AC |
4 ms |
3584 KB |
10_14.txt |
AC |
4 ms |
3584 KB |
10_15.txt |
AC |
4 ms |
3584 KB |
10_16.txt |
AC |
5 ms |
3712 KB |
10_17.txt |
AC |
5 ms |
3712 KB |
20_01.txt |
AC |
198 ms |
7808 KB |
20_02.txt |
AC |
189 ms |
7808 KB |
20_03.txt |
AC |
189 ms |
7808 KB |
20_04.txt |
AC |
29 ms |
4748 KB |
20_05.txt |
AC |
7 ms |
3584 KB |
20_06.txt |
AC |
14 ms |
4480 KB |
20_07.txt |
AC |
8 ms |
3584 KB |
20_08.txt |
AC |
58 ms |
3840 KB |
20_09.txt |
AC |
7 ms |
3584 KB |
20_10.txt |
AC |
62 ms |
3712 KB |
20_11.txt |
AC |
79 ms |
3968 KB |
20_12.txt |
AC |
85 ms |
7424 KB |
20_13.txt |
AC |
152 ms |
7808 KB |
20_14.txt |
AC |
162 ms |
7680 KB |
20_15.txt |
AC |
167 ms |
8952 KB |
20_16.txt |
AC |
177 ms |
8952 KB |