Submission #1369068
Source Code Expand
#include <bits/stdc++.h> #define pii pair<int, int> #define f first #define s second #define pb push_back #define mp make_pair #define ll long long #define ld long double #define sz(v) int(v.size()) #define all(v) v.begin(), v.end() #define y1 what using namespace std; const int N = (int) 2e5 + 10; const int M = (int) 18; const ll big = (1LL << 51); const ll LINF = (ll) 1e18; const int INF = (int) 1e9 + 7; const double EPS = (double) 1e-6; const double PI = 3.14159265359; int n, m, q; int a[N], b[N], c[N], d[N]; vector<int> v[N]; int mx[N]; int main() { #define fn "balls" #ifdef witch freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else // freopen(fn".in", "r", stdin); // freopen(fn".out", "w", stdout); #endif srand(time(0)); cin >> n >> m; while (m--) { int x, y; cin >> x >> y; v[x].pb(y); v[y].pb(x); } cin >> q; for (int i = 1; i <= q; i++) { cin >> a[i] >> b[i] >> c[i]; } for (int i = n; i >= 1; i--) { mx[i] = 0; } for (int i = q; i >= 1; i--) { if (mx[a[i]]) continue; for (int j = 1; j <= n; j++) { d[j] = INF; } queue<int> q; q.push(a[i]); d[a[i]] = 0; while (!q.empty()) { int fr = q.front(); q.pop(); mx[fr] = max(mx[fr], i); if (d[fr] == b[i]) continue; for (auto it : v[fr]) { if (d[fr] + 1 < d[it]) { d[it] = d[fr] + 1; q.push(it); } } } } for (int i = 1; i <= n; i++) { cout << c[mx[i]] << "\n"; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Splatter Painting |
User | Nurlykhan |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1849 Byte |
Status | WA |
Exec Time | 708 ms |
Memory | 12408 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 | 7680 KB |
00_example_02.txt | AC | 3 ms | 7680 KB |
10_01.txt | AC | 4 ms | 7680 KB |
10_02.txt | AC | 3 ms | 7680 KB |
10_03.txt | WA | 3 ms | 7680 KB |
10_04.txt | AC | 3 ms | 7680 KB |
10_05.txt | AC | 4 ms | 7680 KB |
10_06.txt | AC | 3 ms | 7680 KB |
10_07.txt | AC | 4 ms | 7680 KB |
10_08.txt | WA | 6 ms | 7680 KB |
10_09.txt | WA | 6 ms | 7680 KB |
10_10.txt | WA | 6 ms | 7680 KB |
10_11.txt | WA | 6 ms | 7680 KB |
10_12.txt | WA | 6 ms | 7680 KB |
10_13.txt | WA | 5 ms | 7680 KB |
10_14.txt | WA | 5 ms | 7680 KB |
10_15.txt | WA | 5 ms | 7680 KB |
10_16.txt | AC | 6 ms | 7808 KB |
10_17.txt | AC | 6 ms | 7680 KB |
20_01.txt | WA | 701 ms | 11264 KB |
20_02.txt | WA | 706 ms | 11264 KB |
20_03.txt | WA | 708 ms | 11264 KB |
20_04.txt | AC | 27 ms | 8320 KB |
20_05.txt | WA | 7 ms | 7680 KB |
20_06.txt | AC | 185 ms | 8192 KB |
20_07.txt | WA | 8 ms | 7680 KB |
20_08.txt | AC | 48 ms | 7808 KB |
20_09.txt | WA | 7 ms | 7680 KB |
20_10.txt | WA | 48 ms | 7680 KB |
20_11.txt | AC | 62 ms | 7808 KB |
20_12.txt | WA | 273 ms | 11136 KB |
20_13.txt | WA | 581 ms | 11392 KB |
20_14.txt | WA | 567 ms | 11264 KB |
20_15.txt | AC | 144 ms | 12152 KB |
20_16.txt | AC | 144 ms | 12408 KB |