Submission #1586685
Source Code Expand
/*
Till the roof comes off, till the lights go out
Till my legs give out, can�t shut my mouth.
Till the smoke clears out. Am I high? Perhaps
I'ma rip this shit till my bones collapse.
*/
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string.h>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#include <stack>
#include <complex>
#define ll long long
#define X real()
#define Y imag()
#define f first
#define s second
#define angle(a) (atan2((a).imag(), (a).real()))
#define vec(a,b) ((b)-(a))
#define same(p1,p2) (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b) ( (conj(a)*(b)).real() ) // a*b cos(T), if zero -> prep
#define cp(a,b) ( (conj(a)*(b)).imag() ) // a*b sin(T), if zero -> parllel
#define lngth(a) (hypot((a).imag(), (a).real()))
#define normalize(a) (a)/length(a)
using namespace std;
const int N=200005;
typedef pair<ll,int>ii;
typedef pair<ii,int>event;
typedef complex<double>point;
const double EPS = 1e-9;
const int INF=100000;
const double PI = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int n,m,a[N],d[N],c[N],mx[N],sol[N];
vector<int>adj[N];
bool v[N][12];
void bfs(int node,int dep,int col){
if(mx[node]>dep)return;
queue<int>q;
q.push(node);
q.push(dep);
v[node][dep]=1;
if(mx[node]==-1)
sol[node]=col;
mx[node]=dep;
while(q.size()){
node=q.front();
q.pop();
dep=q.front();
q.pop();
if(!dep)continue;
for(int i=0;i<adj[node].size();i++){
int to=adj[node][i];
if(mx[to]>=dep-1)continue;
if(mx[to]==-1)
sol[to]=col;
mx[to]=dep-1;
q.push(to);
q.push(dep-1);
}
}
}
int main()
{
//freopen("test.in","r",stdin);
//freopen("output.txt","w",stdout);
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++){
int a,b;
scanf("%d%d",&a,&b);
adj[a].push_back(b);
adj[b].push_back(a);
}
memset(mx,-1,sizeof(mx));
int q;
scanf("%d",&q);
for(int i=0;i<q;i++)
scanf("%d%d%d",&a[i],&d[i],&c[i]);
memset(sol,0,sizeof(sol));
for(int i=q-1;i>-1;i--){
bfs(a[i],d[i],c[i]);
}
for(int i=1;i<=n;i++)cout<<sol[i]<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Splatter Painting |
User |
vjudge3 |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
2436 Byte |
Status |
AC |
Exec Time |
248 ms |
Memory |
13976 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:81:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
^
./Main.cpp:84:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&a,&b);
^
./Main.cpp:90:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&q);
^
./Main.cpp:92:42: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d",&a[i],&d[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 |
8448 KB |
00_example_02.txt |
AC |
3 ms |
8448 KB |
10_01.txt |
AC |
4 ms |
8448 KB |
10_02.txt |
AC |
3 ms |
8448 KB |
10_03.txt |
AC |
3 ms |
8448 KB |
10_04.txt |
AC |
3 ms |
8448 KB |
10_05.txt |
AC |
4 ms |
8448 KB |
10_06.txt |
AC |
3 ms |
8448 KB |
10_07.txt |
AC |
6 ms |
8448 KB |
10_08.txt |
AC |
8 ms |
8576 KB |
10_09.txt |
AC |
8 ms |
8576 KB |
10_10.txt |
AC |
8 ms |
8576 KB |
10_11.txt |
AC |
7 ms |
8576 KB |
10_12.txt |
AC |
8 ms |
8576 KB |
10_13.txt |
AC |
7 ms |
8576 KB |
10_14.txt |
AC |
7 ms |
8576 KB |
10_15.txt |
AC |
7 ms |
8576 KB |
10_16.txt |
AC |
7 ms |
8576 KB |
10_17.txt |
AC |
7 ms |
8576 KB |
20_01.txt |
AC |
235 ms |
13184 KB |
20_02.txt |
AC |
239 ms |
13184 KB |
20_03.txt |
AC |
248 ms |
13184 KB |
20_04.txt |
AC |
25 ms |
9216 KB |
20_05.txt |
AC |
6 ms |
8448 KB |
20_06.txt |
AC |
148 ms |
9728 KB |
20_07.txt |
AC |
6 ms |
8448 KB |
20_08.txt |
AC |
21 ms |
8832 KB |
20_09.txt |
AC |
6 ms |
8448 KB |
20_10.txt |
AC |
21 ms |
8704 KB |
20_11.txt |
AC |
27 ms |
8832 KB |
20_12.txt |
AC |
178 ms |
12672 KB |
20_13.txt |
AC |
210 ms |
13184 KB |
20_14.txt |
AC |
205 ms |
13056 KB |
20_15.txt |
AC |
218 ms |
13776 KB |
20_16.txt |
AC |
215 ms |
13976 KB |