Submission #1240796
Source Code Expand
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
struct data {
int num;
struct data* Next;
};
struct node {
int color;
struct data* next;
int nextnum = 0;
};
int n, m, q;
struct node Node[100001];
int visit[100001];
void color (int v, int d, int c) {
Node[v].color = c;
int i = v;
visit[i] = 1;
for (struct data* temp = Node[i].next; temp != NULL; temp = temp -> Next) {
if (visit[temp -> num] == 1)
continue;
if (d == 1) {
Node[temp -> num].color = c;
}
else {
Node[temp -> num].color = c;
color (temp -> num, d - 1, c);
}
}
visit[i] = 0;
}
int main () {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) {
Node[i].color = 0;
Node[i].nextnum = 0;
Node[i].next = NULL;
}
for (int i = 0; i < m; i++) {
int a, b;
scanf("%d%d", &a, &b);
struct data* A = (struct data*)malloc(sizeof(struct data));
struct data* B = (struct data*)malloc(sizeof(struct data));
A -> num = b;
B -> num = a;
A -> Next = Node[a].next;
B -> Next = Node[b].next;
Node[a].next = A;
Node[b].next = B;
}
scanf("%d", &q);
memset (visit, 0, sizeof(int) * n);
for (int i = 0; i < q; i++) {
int v, d, c;
scanf("%d%d%d", &v, &d, &c);
color (v, d, c);
}
for (int i = 1; i <= n; i++) {
printf("%d\n", Node[i].color);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Splatter Painting |
User |
shirochan |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1727 Byte |
Status |
WA |
Exec Time |
2104 ms |
Memory |
12416 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:43:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
^
./Main.cpp:51:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &a, &b);
^
./Main.cpp:61:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &q);
^
./Main.cpp:65:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &v, &d, &c);
^
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 |
2 ms |
2560 KB |
00_example_02.txt |
AC |
2 ms |
2560 KB |
10_01.txt |
TLE |
2103 ms |
2560 KB |
10_02.txt |
AC |
2 ms |
2560 KB |
10_03.txt |
WA |
2 ms |
2560 KB |
10_04.txt |
AC |
2 ms |
2560 KB |
10_05.txt |
TLE |
2103 ms |
2560 KB |
10_06.txt |
AC |
2 ms |
2560 KB |
10_07.txt |
AC |
2 ms |
2560 KB |
10_08.txt |
TLE |
2103 ms |
2688 KB |
10_09.txt |
TLE |
2103 ms |
2688 KB |
10_10.txt |
TLE |
2103 ms |
2688 KB |
10_11.txt |
TLE |
2103 ms |
2688 KB |
10_12.txt |
TLE |
2103 ms |
2688 KB |
10_13.txt |
WA |
19 ms |
2688 KB |
10_14.txt |
WA |
5 ms |
2688 KB |
10_15.txt |
WA |
6 ms |
2688 KB |
10_16.txt |
AC |
27 ms |
2688 KB |
10_17.txt |
AC |
26 ms |
2688 KB |
20_01.txt |
TLE |
2104 ms |
10368 KB |
20_02.txt |
TLE |
2104 ms |
10368 KB |
20_03.txt |
TLE |
2103 ms |
12416 KB |
20_04.txt |
TLE |
2104 ms |
5248 KB |
20_05.txt |
TLE |
2103 ms |
2560 KB |
20_06.txt |
WA |
10 ms |
3072 KB |
20_07.txt |
WA |
38 ms |
2560 KB |
20_08.txt |
TLE |
2103 ms |
2944 KB |
20_09.txt |
WA |
4 ms |
2560 KB |
20_10.txt |
TLE |
2103 ms |
2560 KB |
20_11.txt |
TLE |
2103 ms |
2944 KB |
20_12.txt |
TLE |
2104 ms |
8576 KB |
20_13.txt |
TLE |
2104 ms |
8832 KB |
20_14.txt |
TLE |
2104 ms |
8704 KB |
20_15.txt |
TLE |
2104 ms |
9088 KB |
20_16.txt |
TLE |
2104 ms |
9088 KB |