Submission #1886661
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))
#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;
const int MAX = 100100;
const int MIN = 20;
struct Query
{
int x;
int d;
int c;
Query(int x, int d, int c)
{
this->x = x;
this->d = d;
this->c = c;
}
Query(){}
} Q[MAX];
VI g[MAX];
bool U[MAX][MIN];
int C[MAX];
void dfs(int x, int d, int c)
{
if (U[x][d]) return;
if (C[x] == -1) C[x] = c;
U[x][d] = 1;
if (d == 0) return;
FOR (i, 0, SZ(g[x]))
{
int to = g[x][i];
dfs(to, d-1, c);
}
}
int main()
{
//freopen("in.txt", "r", stdin);
//ios::sync_with_stdio(false); cin.tie(0);
int n, m;
scanf("%d%d", &n, &m);
FOR (i, 0, m)
{
int x, y;
scanf("%d%d", &x, &y);
x--;
y--;
g[x].PB(y);
g[y].PB(x);
}
int q;
scanf("%d", &q);
FOR (i, 0, q)
{
int x, d, c;
scanf("%d%d%d", &x, &d, &c);
x--;
c--;
Q[i] = Query(x, d, c);
}
FILL(C, -1);
RFOR(i, q, 0)
{
int x = Q[i].x;
int d = Q[i].d;
int c = Q[i].c;
dfs(x, d, c);
}
FOR (i, 0, n)
{
printf("%d\n", C[i] + 1);
}
}
Submission Info
Submission Time |
|
Task |
B - Splatter Painting |
User |
vjudge1 |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
1506 Byte |
Status |
AC |
Exec Time |
101 ms |
Memory |
9976 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:67:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
^
./Main.cpp:71:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &x, &y);
^
./Main.cpp:80:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &q);
^
./Main.cpp:84:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &x, &d, &c);
^
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 |
2 ms |
3328 KB |
00_example_02.txt |
AC |
2 ms |
3328 KB |
10_01.txt |
AC |
2 ms |
3328 KB |
10_02.txt |
AC |
2 ms |
3328 KB |
10_03.txt |
AC |
2 ms |
3328 KB |
10_04.txt |
AC |
2 ms |
3328 KB |
10_05.txt |
AC |
2 ms |
3328 KB |
10_06.txt |
AC |
2 ms |
3328 KB |
10_07.txt |
AC |
2 ms |
3328 KB |
10_08.txt |
AC |
4 ms |
3456 KB |
10_09.txt |
AC |
4 ms |
3456 KB |
10_10.txt |
AC |
4 ms |
3456 KB |
10_11.txt |
AC |
4 ms |
3456 KB |
10_12.txt |
AC |
4 ms |
3456 KB |
10_13.txt |
AC |
3 ms |
3456 KB |
10_14.txt |
AC |
3 ms |
3328 KB |
10_15.txt |
AC |
3 ms |
3328 KB |
10_16.txt |
AC |
3 ms |
3456 KB |
10_17.txt |
AC |
3 ms |
3456 KB |
20_01.txt |
AC |
101 ms |
9344 KB |
20_02.txt |
AC |
101 ms |
9344 KB |
20_03.txt |
AC |
101 ms |
9216 KB |
20_04.txt |
AC |
16 ms |
4096 KB |
20_05.txt |
AC |
4 ms |
3328 KB |
20_06.txt |
AC |
12 ms |
5248 KB |
20_07.txt |
AC |
4 ms |
3328 KB |
20_08.txt |
AC |
18 ms |
4224 KB |
20_09.txt |
AC |
4 ms |
3456 KB |
20_10.txt |
AC |
18 ms |
4224 KB |
20_11.txt |
AC |
23 ms |
4480 KB |
20_12.txt |
AC |
46 ms |
8192 KB |
20_13.txt |
AC |
73 ms |
9216 KB |
20_14.txt |
AC |
78 ms |
9344 KB |
20_15.txt |
AC |
71 ms |
9848 KB |
20_16.txt |
AC |
71 ms |
9976 KB |