Submission #1495342
Source Code Expand
#include "iostream" #include "climits" #include "list" #include "queue" #include "stack" #include "set" #include "functional" #include "algorithm" #include "string" #include "map" #include "iomanip" #include "random" using namespace std; const long long int MOD = 1000000007; long long int power(long long int x, long long int n, long long int M) { long long int tmp = 1; if (n > 0) { tmp = power(x, n / 2, M); if (n % 2 == 0) tmp = (tmp*tmp) % M; else tmp = (((tmp*tmp) % M)*x) % M; } return tmp; } long long int N, M, K, Q, W, H, L, R; long long int ans; int main() { ios::sync_with_stdio(false); cin >> N >> M; list<int>edge[100001]; for (int i = 0; i < M; i++) { cin >> L >> R; edge[L].push_back(R); edge[R].push_back(L); } cin >> Q; vector<vector<int>>num(N + 1, vector<int>(11, -1)); int a[100001]; int b[100001]; int c[100001]; for (int i = 0; i < Q; i++) { cin >> a[i] >> b[i] >> c[i]; } for(int i=Q-1;i>=0;i--){ queue<pair<int, int>>QQ; QQ.push({ a[i],b[i] }); while (!QQ.empty()) { int cc = QQ.front().second; int cn= QQ.front().first; QQ.pop(); if (num[cn][cc] >= 0)continue; for (int j = 0; j <= cc; j++) { if (num[cn][j] == -1) { num[cn][j] = c[i]; } } for (auto j : edge[cn]) { QQ.push({ j,cc - 1 }); } } } for (int i = 1; i <= N; i++) { if (num[i][0] >= 0)cout << num[i][0] << endl; else cout << "0\n"; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Splatter Painting |
User | olphe |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1502 Byte |
Status | AC |
Exec Time | 291 ms |
Memory | 18728 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 | 2560 KB |
00_example_02.txt | AC | 2 ms | 1792 KB |
10_01.txt | AC | 3 ms | 1920 KB |
10_02.txt | AC | 2 ms | 1792 KB |
10_03.txt | AC | 2 ms | 2816 KB |
10_04.txt | AC | 2 ms | 2304 KB |
10_05.txt | AC | 2 ms | 2560 KB |
10_06.txt | AC | 2 ms | 1792 KB |
10_07.txt | AC | 2 ms | 2048 KB |
10_08.txt | AC | 7 ms | 2176 KB |
10_09.txt | AC | 7 ms | 2176 KB |
10_10.txt | AC | 7 ms | 2176 KB |
10_11.txt | AC | 7 ms | 2176 KB |
10_12.txt | AC | 7 ms | 2176 KB |
10_13.txt | AC | 5 ms | 2176 KB |
10_14.txt | AC | 5 ms | 2176 KB |
10_15.txt | AC | 4 ms | 2176 KB |
10_16.txt | AC | 7 ms | 2176 KB |
10_17.txt | AC | 7 ms | 2176 KB |
20_01.txt | AC | 281 ms | 18304 KB |
20_02.txt | AC | 289 ms | 18304 KB |
20_03.txt | AC | 291 ms | 18304 KB |
20_04.txt | AC | 35 ms | 5384 KB |
20_05.txt | AC | 5 ms | 2048 KB |
20_06.txt | AC | 22 ms | 10240 KB |
20_07.txt | AC | 6 ms | 2944 KB |
20_08.txt | AC | 36 ms | 3712 KB |
20_09.txt | AC | 6 ms | 2048 KB |
20_10.txt | AC | 36 ms | 2944 KB |
20_11.txt | AC | 48 ms | 3584 KB |
20_12.txt | AC | 163 ms | 16384 KB |
20_13.txt | AC | 260 ms | 17152 KB |
20_14.txt | AC | 251 ms | 16896 KB |
20_15.txt | AC | 252 ms | 18728 KB |
20_16.txt | AC | 258 ms | 18728 KB |