Submission #1196797


Source Code Expand

Copy
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

struct ve{
  vector<int> d;
  int c;
};
ve x[100001];
int co[100001];
int N, M, Q;
int vv[100001], dd[100001], cc[100001];
void dfs(int n, int prev, int d, int c, int l){
  if(d > l) return;
  if(co[n] == 0) co[n] = c;
  for(int i = 0; i < x[n].d.size(); i++){
    if(x[n].d[i] != prev){
      dfs(x[n].d[i], n, d+1, c, l);
    }
  }
}

int main(){
  cin >> N >> M;
  fill(co, co+N, 0);
  for(int i = 0; i < N; i++)  co[i] = 0;
  for(int i = 0; i < M; i++){
    int a, b; cin >> a >> b;
    a--;  b--;
    x[a].d.push_back(b);
    x[b].d.push_back(a);
  }
  cin >> Q;
  for(int i = 0; i < Q; i++){
    cin >> vv[i] >> dd[i] >> cc[i];
    vv[i]--;
  }

  for(int i = Q-1; i >= 0; i--){
    dfs(vv[i], vv[i], 0, cc[i], dd[i]);
  }

  for(int i = 0; i < N; i++)  cout << co[i] << endl;

  return 0;
}

Submission Info

Submission Time
Task B - Splatter Painting
User bomac1
Language C++14 (GCC 5.4.1)
Score 0
Code Size 988 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 00_example_01.txt, 00_example_02.txt
Subtask1 0 / 200 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 0 / 500 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 2 ms 3328 KB
00_example_02.txt 2 ms 3328 KB
10_01.txt 1257 ms 3456 KB
10_02.txt 2 ms 3328 KB
10_03.txt 2 ms 3328 KB
10_04.txt 2 ms 3328 KB
10_05.txt
10_06.txt 5 ms 3328 KB
10_07.txt 5 ms 3328 KB
10_08.txt 15 ms 3456 KB
10_09.txt 13 ms 3456 KB
10_10.txt 13 ms 3456 KB
10_11.txt 15 ms 3456 KB
10_12.txt 14 ms 3456 KB
10_13.txt 7 ms 3456 KB
10_14.txt 7 ms 3456 KB
10_15.txt 6 ms 3456 KB
10_16.txt 32 ms 3456 KB
10_17.txt 32 ms 3456 KB
20_01.txt
20_02.txt
20_03.txt
20_04.txt
20_05.txt 20 ms 3456 KB
20_06.txt 147 ms 4096 KB
20_07.txt 11 ms 3456 KB
20_08.txt
20_09.txt 9 ms 3456 KB
20_10.txt 411 ms 4352 KB
20_11.txt
20_12.txt 233 ms 7040 KB
20_13.txt 340 ms 7936 KB
20_14.txt 361 ms 8064 KB
20_15.txt
20_16.txt