Submission #1494047
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <cstring> #include <queue> #include <stack> #include <math.h> #include <iterator> #include <vector> #include <string> #include <set> #include <math.h> #include <iostream> #include <random> #include<map> #include <iomanip> #include <time.h> #include <stdlib.h> #include <list> #include <typeinfo> #include <list> #include <set> #include <cassert> #include<fstream> #include <unordered_map> using namespace std; #define eps 0.00000001 #define LONG_INF 10000000000000000 #define GOLD 1.61803398874989484820458 #define MAX_MOD 1000000007 #define f(n) for(int i=0;i<n;++i) #define REP(i,n) for(long long i = 0;i < n;++i) int maxium[1000000] = {}; int color[1000000] = {}; vector<int> vertex[1000000]; int main() { int n, m,query; cin >> n >> m; REP(i, m) { int a, b; cin >> a >> b; vertex[a].push_back(b); vertex[b].push_back(a); } vector<pair<int, int>> hoge; vector<int> colorful; cin >> query; REP(i, query) { int a, b; cin >> a >> b; hoge.push_back(make_pair(a, b)); int c; cin >> c; colorful.push_back(c); } reverse(colorful.begin(), colorful.end()); reverse(hoge.begin(), hoge.end()); for (int i = 0;i < query;++i) { if (maxium[hoge[i].first] < hoge[i].second+1) { queue<pair<int, int>> nya; map<int, int> visited; nya.push(make_pair(hoge[i].first, hoge[i].second+1)); maxium[hoge[i].first] = hoge[i].second + 1; while (nya.empty() == false) { pair<int, int> now = nya.front();nya.pop(); if (visited[now.first] == false) { visited[now.first] = true; if (color[now.first] == 0)color[now.first] = colorful[i] + 1; now.second--; if (now.second != 0) { for (int q = 0;q < vertex[now.first].size();++q) { if (maxium[vertex[now.first][q]] < now.second) { maxium[vertex[now.first][q]] = now.second; nya.push(make_pair(vertex[now.first][q], now.second)); } } } } } } } for (int i = 1;i <= n;++i) { cout << max(color[i] - 1,0) << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Splatter Painting |
User | kotamanegi |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 2193 Byte |
Status | AC |
Exec Time | 506 ms |
Memory | 36684 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 | 10 ms | 26880 KB |
00_example_02.txt | AC | 10 ms | 26880 KB |
10_01.txt | AC | 11 ms | 26880 KB |
10_02.txt | AC | 10 ms | 26880 KB |
10_03.txt | AC | 10 ms | 26880 KB |
10_04.txt | AC | 10 ms | 26880 KB |
10_05.txt | AC | 11 ms | 26880 KB |
10_06.txt | AC | 10 ms | 26880 KB |
10_07.txt | AC | 12 ms | 26880 KB |
10_08.txt | AC | 16 ms | 27008 KB |
10_09.txt | AC | 16 ms | 27008 KB |
10_10.txt | AC | 16 ms | 27008 KB |
10_11.txt | AC | 17 ms | 27008 KB |
10_12.txt | AC | 16 ms | 27008 KB |
10_13.txt | AC | 14 ms | 26880 KB |
10_14.txt | AC | 14 ms | 26880 KB |
10_15.txt | AC | 14 ms | 26880 KB |
10_16.txt | AC | 17 ms | 27008 KB |
10_17.txt | AC | 17 ms | 27008 KB |
20_01.txt | AC | 387 ms | 31736 KB |
20_02.txt | AC | 381 ms | 31736 KB |
20_03.txt | AC | 385 ms | 31736 KB |
20_04.txt | AC | 53 ms | 27776 KB |
20_05.txt | AC | 15 ms | 27008 KB |
20_06.txt | AC | 157 ms | 27136 KB |
20_07.txt | AC | 15 ms | 27008 KB |
20_08.txt | AC | 56 ms | 28276 KB |
20_09.txt | AC | 15 ms | 27008 KB |
20_10.txt | AC | 56 ms | 28280 KB |
20_11.txt | AC | 72 ms | 28532 KB |
20_12.txt | AC | 237 ms | 30208 KB |
20_13.txt | AC | 320 ms | 31604 KB |
20_14.txt | AC | 330 ms | 31732 KB |
20_15.txt | AC | 434 ms | 36424 KB |
20_16.txt | AC | 506 ms | 36684 KB |