AtCoder Grand Contest 012

Submission #1352153

Source codeソースコード

#include<bits/stdc++.h>
using namespace std;
int n, m, q, col[100005][15];
int a[100005], b[100005], c[100005];
vector<int> adj[100005];

void bfs (int I, int D, int V) {
	col[I][D] = V;
	if(D == 0) return;
	queue<pair<int,int> > Q;
	Q.push({I, D});
	while(!Q.empty()) {
		int A = Q.front().first, B = Q.front().second;
		Q.pop();
		for(auto &X : adj[A]) {
			if(col[X][B-1]) continue;
			col[X][B-1] = V;
			if(B-1 > 0) Q.push({X, B-1});
		}
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	scanf("%d",&q);
	for(int i=1;i<=q;i++) {
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	for(int i=q;i>=1;i--) {
		if(!col[a[i]][b[i]]) bfs(a[i], b[i], i);
	}
	for(int i=1;i<=n;i++) {
		int A = 0;
		for(int j=0;j<=10;j++) {
			A = max(A, col[i][j]);
		}
		printf("%d\n",c[A]);
	}
}

Submission

Task問題 B - Splatter Painting
User nameユーザ名 khsoo01
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 700
Source lengthソースコード長 915 Byte
File nameファイル名
Exec time実行時間 115 ms
Memory usageメモリ使用量 13992 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:25:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
^
./Main.cpp:28:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&A,&B);
^
./Main.cpp:32:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&q);
^
./Main.cpp:34:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d",&a[i],&b[i],&c[i]);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - 00_example_01.txt,00_example_02.txt
Subtask1 200 / 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 500 / 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_example_01.txt AC 3 ms 4352 KB
00_example_02.txt AC 3 ms 4352 KB
10_01.txt AC 3 ms 4352 KB
10_02.txt AC 3 ms 4352 KB
10_03.txt AC 3 ms 4352 KB
10_04.txt AC 3 ms 4352 KB
10_05.txt AC 3 ms 4352 KB
10_06.txt AC 3 ms 4352 KB
10_07.txt AC 3 ms 4352 KB
10_08.txt AC 4 ms 4352 KB
10_09.txt AC 4 ms 4352 KB
10_10.txt AC 4 ms 4352 KB
10_11.txt AC 4 ms 4352 KB
10_12.txt AC 4 ms 4352 KB
10_13.txt AC 4 ms 4352 KB
10_14.txt AC 3 ms 4352 KB
10_15.txt AC 3 ms 4352 KB
10_16.txt AC 4 ms 4480 KB
10_17.txt AC 4 ms 4480 KB
20_01.txt AC 115 ms 12800 KB
20_02.txt AC 112 ms 12800 KB
20_03.txt AC 112 ms 12800 KB
20_04.txt AC 16 ms 5120 KB
20_05.txt AC 4 ms 4352 KB
20_06.txt AC 14 ms 9472 KB
20_07.txt AC 5 ms 4352 KB
20_08.txt AC 18 ms 4480 KB
20_09.txt AC 4 ms 4352 KB
20_10.txt AC 18 ms 4352 KB
20_11.txt AC 23 ms 4480 KB
20_12.txt AC 49 ms 12288 KB
20_13.txt AC 84 ms 12672 KB
20_14.txt AC 89 ms 12416 KB
20_15.txt AC 78 ms 13992 KB
20_16.txt AC 78 ms 13992 KB