Submission #1352146
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) {
queue<pair<int,int> > Q;
col[I][D] = V;
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) 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 |
0 |
Code Size |
890 Byte |
Status |
WA |
Exec Time |
153 ms |
Memory |
13992 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:24: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:27: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:31:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&q);
^
./Main.cpp:33: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 |
0 / 200 |
0 / 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 |
WA |
4 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 |
WA |
5 ms |
4352 KB |
10_09.txt |
WA |
5 ms |
4352 KB |
10_10.txt |
WA |
5 ms |
4352 KB |
10_11.txt |
WA |
5 ms |
4352 KB |
10_12.txt |
WA |
5 ms |
4352 KB |
10_13.txt |
WA |
4 ms |
4352 KB |
10_14.txt |
WA |
4 ms |
4352 KB |
10_15.txt |
WA |
4 ms |
4352 KB |
10_16.txt |
AC |
4 ms |
4480 KB |
10_17.txt |
AC |
4 ms |
4480 KB |
20_01.txt |
WA |
153 ms |
13312 KB |
20_02.txt |
WA |
145 ms |
13184 KB |
20_03.txt |
WA |
142 ms |
13184 KB |
20_04.txt |
WA |
19 ms |
5120 KB |
20_05.txt |
WA |
4 ms |
4352 KB |
20_06.txt |
WA |
15 ms |
9472 KB |
20_07.txt |
WA |
5 ms |
4352 KB |
20_08.txt |
AC |
18 ms |
4480 KB |
20_09.txt |
WA |
5 ms |
4352 KB |
20_10.txt |
AC |
18 ms |
4352 KB |
20_11.txt |
AC |
23 ms |
4480 KB |
20_12.txt |
WA |
100 ms |
12288 KB |
20_13.txt |
WA |
126 ms |
12568 KB |
20_14.txt |
WA |
125 ms |
12352 KB |
20_15.txt |
AC |
82 ms |
13992 KB |
20_16.txt |
AC |
82 ms |
13992 KB |