Submission #2374753
Source Code Expand
#include <stdint.h> #include <stdio.h> #include <deque> #include <vector> unsigned readUnsigned() { int c; do { c = ::getchar_unlocked(); } while (c < '0'); unsigned result = c - '0'; while ((c = ::getchar_unlocked()) >= '0') { result *= 10; result += c - '0'; } return result; } void writeUnsignedLn(unsigned x) { static const unsigned MAX_DIGITS = 10; static const unsigned BUF_SIZE = MAX_DIGITS + 1; static char buffer[BUF_SIZE] = {0}; buffer[BUF_SIZE - 1] = '\n'; unsigned i = BUF_SIZE - 1; do { buffer[--i] = x % 10 + '0'; x /= 10; } while (x); ::fwrite_unlocked(buffer + i, 1, BUF_SIZE - i, stdout); } struct Node { unsigned color = 0; unsigned colordist = 0; std::vector<unsigned> edges; }; struct Paint { unsigned v = 0; unsigned color = 0; unsigned dist = 0; Paint(unsigned v = 0, unsigned color = 0, unsigned dist = 0) : v(v), color(color), dist(dist) { } }; Node NODE[100 * 1000]; int main() { unsigned N = readUnsigned(); unsigned M = readUnsigned(); for (unsigned i = 0; i < M; ++i) { unsigned x = readUnsigned(); unsigned y = readUnsigned(); --x, --y; NODE[x].edges.push_back(y); NODE[y].edges.push_back(x); } unsigned numPaint = readUnsigned(); std::deque<Paint> jobs; for (unsigned i = 0; i < numPaint; ++i) { unsigned v = readUnsigned(); unsigned dist = readUnsigned(); unsigned color = readUnsigned(); jobs.push_front(Paint(v - 1, color, dist + 1)); } while (!jobs.empty()) { Paint P = jobs.front(); jobs.pop_front(); if (NODE[P.v].colordist >= P.dist) { continue; } if (NODE[P.v].color == 0) { NODE[P.v].color = P.color; } NODE[P.v].colordist = P.dist; if (P.dist == 1) { continue; } for (unsigned u : NODE[P.v].edges) { if (NODE[u].colordist < P.dist - 1) { jobs.push_front(Paint(u, P.color, P.dist - 1)); } } } for (unsigned i = 0; i < N; ++i) { writeUnsignedLn(NODE[i].color); } }
Submission Info
Submission Time | |
---|---|
Task | B - Splatter Painting |
User | vjudge2 |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 2242 Byte |
Status | AC |
Exec Time | 49 ms |
Memory | 9364 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 | 3328 KB |
00_example_02.txt | AC | 3 ms | 3328 KB |
10_01.txt | AC | 3 ms | 3456 KB |
10_02.txt | AC | 3 ms | 3328 KB |
10_03.txt | AC | 3 ms | 3328 KB |
10_04.txt | AC | 3 ms | 3328 KB |
10_05.txt | AC | 3 ms | 3328 KB |
10_06.txt | AC | 3 ms | 3328 KB |
10_07.txt | AC | 3 ms | 3328 KB |
10_08.txt | AC | 3 ms | 3456 KB |
10_09.txt | AC | 3 ms | 3456 KB |
10_10.txt | AC | 3 ms | 3456 KB |
10_11.txt | AC | 3 ms | 3456 KB |
10_12.txt | AC | 3 ms | 3456 KB |
10_13.txt | AC | 3 ms | 3456 KB |
10_14.txt | AC | 3 ms | 3456 KB |
10_15.txt | AC | 3 ms | 3456 KB |
10_16.txt | AC | 3 ms | 3456 KB |
10_17.txt | AC | 3 ms | 3456 KB |
20_01.txt | AC | 48 ms | 7616 KB |
20_02.txt | AC | 48 ms | 7616 KB |
20_03.txt | AC | 49 ms | 7492 KB |
20_04.txt | AC | 9 ms | 4096 KB |
20_05.txt | AC | 3 ms | 3456 KB |
20_06.txt | AC | 4 ms | 3584 KB |
20_07.txt | AC | 3 ms | 3456 KB |
20_08.txt | AC | 6 ms | 4352 KB |
20_09.txt | AC | 3 ms | 3456 KB |
20_10.txt | AC | 6 ms | 4352 KB |
20_11.txt | AC | 8 ms | 4608 KB |
20_12.txt | AC | 25 ms | 6656 KB |
20_13.txt | AC | 37 ms | 7680 KB |
20_14.txt | AC | 37 ms | 7684 KB |
20_15.txt | AC | 27 ms | 9364 KB |
20_16.txt | AC | 30 ms | 9364 KB |