Submission #1369072
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--) { 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 | 200 |
Code Size | 1803 Byte |
Status | TLE |
Exec Time | 2104 ms |
Memory | 12024 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 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 | AC | 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 | AC | 10 ms | 7680 KB |
10_09.txt | AC | 10 ms | 7680 KB |
10_10.txt | AC | 10 ms | 7680 KB |
10_11.txt | AC | 10 ms | 7680 KB |
10_12.txt | AC | 10 ms | 7680 KB |
10_13.txt | AC | 5 ms | 7680 KB |
10_14.txt | AC | 5 ms | 7680 KB |
10_15.txt | AC | 5 ms | 7680 KB |
10_16.txt | AC | 29 ms | 7808 KB |
10_17.txt | AC | 28 ms | 7680 KB |
20_01.txt | TLE | 2104 ms | 10880 KB |
20_02.txt | TLE | 2104 ms | 10880 KB |
20_03.txt | TLE | 2104 ms | 10880 KB |
20_04.txt | AC | 97 ms | 8320 KB |
20_05.txt | AC | 14 ms | 7680 KB |
20_06.txt | AC | 189 ms | 8192 KB |
20_07.txt | AC | 12 ms | 7680 KB |
20_08.txt | AC | 1341 ms | 7808 KB |
20_09.txt | AC | 11 ms | 7680 KB |
20_10.txt | AC | 158 ms | 7680 KB |
20_11.txt | AC | 1989 ms | 7808 KB |
20_12.txt | AC | 423 ms | 11136 KB |
20_13.txt | TLE | 2104 ms | 11008 KB |
20_14.txt | TLE | 2104 ms | 10880 KB |
20_15.txt | TLE | 2104 ms | 12024 KB |
20_16.txt | TLE | 2104 ms | 12024 KB |