Submission #1197503
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second
int n, m;
vector<int>edge[100010];
int col[100010];
typedef tuple<int,int,int> t3;
int q;
t3 Q[100010];
int dst[100010];
int tst[100010];
int now;
void bfs(int v, int d, int c){
if(col[v]) return;
queue<int>q;
++now;
tst[v]=now; dst[v]=0;
q.push(v);
while(q.size()){
int x=q.front(); q.pop();
col[x]=c;
if(dst[x] == d) continue;
for(int y:edge[x]){
if(col[y]) continue;
if(tst[y]!=now) tst[y]=now, dst[y]=1e9;
if(dst[y] > dst[x]+1){
dst[y]=dst[x]+1;
q.push(y);
}
}
}
}
int main()
{
read(n,m);
for(int i=0; i<m; ++i){
int a, b; read(a,b);
edge[a].pb(b); edge[b].pb(a);
}
read(q);
for(int i=0; i<q; ++i){
int v, d, c;
read(v, d, c);
Q[i]=make_tuple(v, d, c);
}
for(int i=q-1; 0<=i; --i){
int v, d, c; tie(v, d, c) = Q[i];
bfs(v, d, c);
}
for(int i=1; i<=n; ++i) printf("%d\n", col[i]);
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Splatter Painting |
User |
Namnamseo |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1457 Byte |
Status |
WA |
Exec Time |
89 ms |
Memory |
9208 KB |
Compile Error
./Main.cpp: In function ‘void read(int&)’:
./Main.cpp:6:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
void read(int& x){ scanf("%d",&x); }
^
./Main.cpp: In function ‘void read(ll&)’:
./Main.cpp:7:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
void read(ll& x){ scanf("%lld",&x); }
^
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 |
2944 KB |
00_example_02.txt |
WA |
2 ms |
2944 KB |
10_01.txt |
AC |
2 ms |
2944 KB |
10_02.txt |
AC |
2 ms |
2944 KB |
10_03.txt |
WA |
2 ms |
2944 KB |
10_04.txt |
AC |
2 ms |
2944 KB |
10_05.txt |
AC |
2 ms |
2944 KB |
10_06.txt |
AC |
2 ms |
2944 KB |
10_07.txt |
AC |
2 ms |
2944 KB |
10_08.txt |
WA |
4 ms |
3072 KB |
10_09.txt |
WA |
4 ms |
3072 KB |
10_10.txt |
WA |
4 ms |
3072 KB |
10_11.txt |
WA |
4 ms |
3072 KB |
10_12.txt |
WA |
4 ms |
3072 KB |
10_13.txt |
WA |
3 ms |
2944 KB |
10_14.txt |
WA |
3 ms |
2944 KB |
10_15.txt |
WA |
3 ms |
2944 KB |
10_16.txt |
AC |
3 ms |
3072 KB |
10_17.txt |
AC |
3 ms |
3072 KB |
20_01.txt |
WA |
89 ms |
8064 KB |
20_02.txt |
WA |
85 ms |
8064 KB |
20_03.txt |
WA |
89 ms |
8064 KB |
20_04.txt |
AC |
14 ms |
3712 KB |
20_05.txt |
WA |
4 ms |
2944 KB |
20_06.txt |
AC |
12 ms |
3968 KB |
20_07.txt |
WA |
4 ms |
2944 KB |
20_08.txt |
AC |
21 ms |
3840 KB |
20_09.txt |
WA |
4 ms |
2944 KB |
20_10.txt |
WA |
21 ms |
3840 KB |
20_11.txt |
AC |
27 ms |
4096 KB |
20_12.txt |
WA |
46 ms |
6912 KB |
20_13.txt |
WA |
74 ms |
7936 KB |
20_14.txt |
WA |
72 ms |
8064 KB |
20_15.txt |
AC |
70 ms |
9080 KB |
20_16.txt |
AC |
70 ms |
9208 KB |