Submission #1195323


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int N, M, Q;
VI G[100000];

void bfs(int u, int d, int c, VI& ans){
  queue<int> q;
  VI dist(N, 1e9);
  q.push(u);
  dist[u] = 0;

  while(!q.empty()){
	u = q.front();
	q.pop();

	if(dist[u] > d) continue;
	if(ans[u] == 0)
	  ans[u] = c;

	for(int to: G[u]){
	  if(dist[to] > dist[u]+1){
		q.push(to);
		dist[to] = dist[u]+1;
	  }
	}
  }
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cin >> N >> M;
  if(N > 2000 || M > 2000 || Q > 2000) return 1;
  REP(i,M){
	int a, b; cin >> a >> b;
	--a;
	--b;
	G[a].PB(b);
	G[b].PB(a);
  }
  cin >> Q;
  VI vs(Q), ds(Q), cs(Q);
  REP(q,Q){
	cin >> vs[q] >> ds[q] >> cs[q];
	--vs[q];
  }

  VI ans(N);
  for(int q=Q-1;q>=0;--q){
	bfs(vs[q], ds[q], cs[q], ans);
  }

  REP(i,N) cout << ans[i] << endl;

  return 0;
}

Submission Info

Submission Time
Task B - Splatter Painting
User okaduki
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1901 Byte
Status RE
Exec Time 169 ms
Memory 3456 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 0 / 500
Status
AC × 2
AC × 19
AC × 23
RE × 12
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 2560 KB
10_01.txt AC 3 ms 2688 KB
10_02.txt AC 2 ms 2560 KB
10_03.txt AC 2 ms 2560 KB
10_04.txt AC 2 ms 2560 KB
10_05.txt AC 3 ms 2688 KB
10_06.txt AC 2 ms 2560 KB
10_07.txt AC 5 ms 2560 KB
10_08.txt AC 13 ms 2688 KB
10_09.txt AC 12 ms 2688 KB
10_10.txt AC 12 ms 2688 KB
10_11.txt AC 12 ms 2688 KB
10_12.txt AC 12 ms 2688 KB
10_13.txt AC 6 ms 2688 KB
10_14.txt AC 6 ms 2688 KB
10_15.txt AC 6 ms 2688 KB
10_16.txt AC 33 ms 2688 KB
10_17.txt AC 33 ms 2688 KB
20_01.txt RE 2 ms 2560 KB
20_02.txt RE 2 ms 2560 KB
20_03.txt RE 2 ms 2560 KB
20_04.txt RE 2 ms 2560 KB
20_05.txt AC 14 ms 2688 KB
20_06.txt RE 2 ms 2560 KB
20_07.txt AC 10 ms 2688 KB
20_08.txt RE 2 ms 2560 KB
20_09.txt AC 9 ms 2688 KB
20_10.txt AC 169 ms 3456 KB
20_11.txt RE 2 ms 2560 KB
20_12.txt RE 2 ms 2560 KB
20_13.txt RE 2 ms 2560 KB
20_14.txt RE 2 ms 2560 KB
20_15.txt RE 2 ms 2560 KB
20_16.txt RE 2 ms 2560 KB