Submission #1352153
Source Code Expand
#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 Info
Submission Time |
|
Task |
B - Splatter Painting |
User |
khsoo01 |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
915 Byte |
Status |
AC |
Exec Time |
115 ms |
Memory |
13992 KB |
Compile Error
./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]);
^
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 |
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 |