Submission #1195351
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 5; const int M = 1e9 + 7; vector <int> v[N]; int color[N]; int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int n, m, x, y, q; cin >> n >> m; for(int i = 0; i < m; i++) { cin >> x >> y; v[x].push_back(y); v[y].push_back(x); } cin >> q; while(q--) { int u, d, c; cin >> u >> d >> c; queue <int> qu; bool visit[N]; int level[N]; memset(level, 0, sizeof(level)); memset(visit, false, sizeof(visit)); qu.push(u); color[u] = c; visit[u] = true; level[u] = 1; while(!qu.empty()) { int j = qu.front(); if(level[j] == d + 1) break; qu.pop(); for(int i = 0; i < v[j].size(); i++) { if(!visit[v[j][i]]) { qu.push(v[j][i]); color[v[j][i]] = c; level[v[j][i]] = level[j] + 1; visit[v[j][i]] = true;; } } } while(!qu.empty()) { qu.pop(); } } for(int i = 1; i <= n; i++) cout << color[i] << "\n"; }
Submission Info
Submission Time | |
---|---|
Task | B - Splatter Painting |
User | fireace |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 1341 Byte |
Status | TLE |
Exec Time | 2104 ms |
Memory | 8448 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 | 3072 KB |
00_example_02.txt | AC | 3 ms | 3072 KB |
10_01.txt | AC | 3 ms | 3072 KB |
10_02.txt | AC | 3 ms | 3072 KB |
10_03.txt | AC | 4 ms | 3072 KB |
10_04.txt | AC | 3 ms | 3072 KB |
10_05.txt | AC | 3 ms | 3072 KB |
10_06.txt | AC | 5 ms | 3072 KB |
10_07.txt | AC | 4 ms | 3072 KB |
10_08.txt | AC | 54 ms | 3200 KB |
10_09.txt | AC | 54 ms | 3200 KB |
10_10.txt | AC | 54 ms | 3200 KB |
10_11.txt | AC | 54 ms | 3200 KB |
10_12.txt | AC | 54 ms | 3200 KB |
10_13.txt | AC | 13 ms | 3200 KB |
10_14.txt | AC | 6 ms | 3200 KB |
10_15.txt | AC | 4 ms | 3200 KB |
10_16.txt | AC | 78 ms | 3200 KB |
10_17.txt | AC | 78 ms | 3200 KB |
20_01.txt | TLE | 2104 ms | 8320 KB |
20_02.txt | TLE | 2104 ms | 6400 KB |
20_03.txt | TLE | 2104 ms | 6272 KB |
20_04.txt | AC | 98 ms | 3840 KB |
20_05.txt | AC | 143 ms | 3072 KB |
20_06.txt | AC | 127 ms | 3712 KB |
20_07.txt | AC | 165 ms | 3072 KB |
20_08.txt | TLE | 2103 ms | 3200 KB |
20_09.txt | AC | 135 ms | 3072 KB |
20_10.txt | AC | 1924 ms | 3072 KB |
20_11.txt | TLE | 2103 ms | 3200 KB |
20_12.txt | AC | 280 ms | 6656 KB |
20_13.txt | AC | 1866 ms | 8448 KB |
20_14.txt | TLE | 2104 ms | 6400 KB |
20_15.txt | TLE | 2104 ms | 7416 KB |
20_16.txt | TLE | 2104 ms | 7416 KB |