Submission #1196811


Source Code Expand

Copy
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

void bfs(int, int, int);

vector<int> adj[100001];
int color[100001]={0, };
queue<int> q;

int main() {
	int n, m, q;
	scanf("%d %d", &n, &m);
	while(m--) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);	
	}
	scanf("%d", &q);
	while(q--) {
		int v, d, c;
		scanf("%d %d %d", &v, &d, &c);
		bfs(v, d, c);
	}

	for(int i=1; i<=n; i++) 
		printf("%d\n", color[i]);

	return 0;
}

void bfs(int v, int d, int c) {
	q=queue<int>();
	bool visited[100001]={false, };

	visited[v]=true;
	color[v]=c;
	q.push(v);
	while(!q.empty()) {
		int qsize=q.size();
		while(qsize--) {
			int here=q.front(); q.pop();
			for(int i=0; i<adj[here].size(); i++) {
				int there=adj[here][i];
				if(visited[there]) continue;
				visited[there]=true;
				q.push(there);
				color[there]=c;
			}
		}
		d--;
		if(d==0) break;
	}
}

Submission Info

Submission Time
Task B - Splatter Painting
User yohan5050
Language C++14 (GCC 5.4.1)
Score 0
Code Size 972 Byte
Status
Exec Time 2104 ms
Memory 7032 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:14:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
                        ^
./Main.cpp:17:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &u, &v);
                         ^
./Main.cpp:21:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &q);
                 ^
./Main.cpp:24:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &v, &d, &c);
                                ^

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 2688 KB
00_example_02.txt 2 ms 2688 KB
10_01.txt 3 ms 2688 KB
10_02.txt 2 ms 2688 KB
10_03.txt 2 ms 2688 KB
10_04.txt 2 ms 2688 KB
10_05.txt 3 ms 2688 KB
10_06.txt 3 ms 2688 KB
10_07.txt 3 ms 2688 KB
10_08.txt 25 ms 2816 KB
10_09.txt 25 ms 2688 KB
10_10.txt 25 ms 2816 KB
10_11.txt 25 ms 2816 KB
10_12.txt 25 ms 2816 KB
10_13.txt 6 ms 2816 KB
10_14.txt 4 ms 2688 KB
10_15.txt 4 ms 2688 KB
10_16.txt 37 ms 2816 KB
10_17.txt 36 ms 2816 KB
20_01.txt
20_02.txt
20_03.txt
20_04.txt 100 ms 3456 KB
20_05.txt 31 ms 2688 KB
20_06.txt 27 ms 3328 KB
20_07.txt 29 ms 2688 KB
20_08.txt
20_09.txt 24 ms 2688 KB
20_10.txt 404 ms 2688 KB
20_11.txt
20_12.txt
20_13.txt
20_14.txt
20_15.txt
20_16.txt