Submission #1587961


Source Code Expand

//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//


#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>



#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(ll (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1000000000000000000ll
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;

const int N = 200005;
int n,m,q,a[N] , c[N];

bool vis[N][12];
vi adjL[N];


void dfs(int node,int d,int color) {
    if(d == -1 || vis[node][d]) return;
    vis[node][d] = true;
    if(!c[node]) c[node] = color;
    for(int ch:adjL[node]) dfs(ch, d-1, color);
}

struct query {
    int v,d,c;
}qs[N];
int main()
{
    scanf("%d%d",&n,&m);
    
    lp(i, 1, m) {
        int a,b;
        scanf("%d%d",&a,&b);
        adjL[a].pb(b),adjL[b].pb(a);
    }
    
    scanf("%d",&q);
    lp(i, 1, q) scanf("%d%d%d",&qs[i].v,&qs[i].d,&qs[i].c);
    
    lpd(i, q, 1) dfs(qs[i].v, qs[i].d, qs[i].c);
    
    lp(i, 1, n) printf("%d\n",c[i]);
    
    return 0;
}
/*
 
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);

Submission Info

Submission Time
Task B - Splatter Painting
User vjudge1
Language C++14 (GCC 5.4.1)
Score 700
Code Size 3316 Byte
Status AC
Exec Time 93 ms
Memory 13560 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:114: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:118: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:122:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&q);
                   ^
./Main.cpp:123:59: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     lp(i, 1, q) scanf("%d%d%d",&qs[i].v,&qs[i].d,&qs[i].c);
                                                           ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 500 / 500
Status
AC × 2
AC × 19
AC × 35
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 2 ms 8448 KB
10_01.txt AC 3 ms 8448 KB
10_02.txt AC 2 ms 8448 KB
10_03.txt AC 2 ms 8448 KB
10_04.txt AC 2 ms 8448 KB
10_05.txt AC 3 ms 8448 KB
10_06.txt AC 3 ms 8448 KB
10_07.txt AC 3 ms 8448 KB
10_08.txt AC 4 ms 8576 KB
10_09.txt AC 4 ms 8576 KB
10_10.txt AC 4 ms 8576 KB
10_11.txt AC 4 ms 8576 KB
10_12.txt AC 4 ms 8576 KB
10_13.txt AC 3 ms 8448 KB
10_14.txt AC 3 ms 8448 KB
10_15.txt AC 4 ms 8448 KB
10_16.txt AC 3 ms 8576 KB
10_17.txt AC 3 ms 8576 KB
20_01.txt AC 93 ms 12800 KB
20_02.txt AC 92 ms 12800 KB
20_03.txt AC 92 ms 12800 KB
20_04.txt AC 16 ms 9088 KB
20_05.txt AC 4 ms 8576 KB
20_06.txt AC 11 ms 8704 KB
20_07.txt AC 4 ms 8576 KB
20_08.txt AC 18 ms 9344 KB
20_09.txt AC 4 ms 8576 KB
20_10.txt AC 18 ms 9344 KB
20_11.txt AC 23 ms 9728 KB
20_12.txt AC 44 ms 11776 KB
20_13.txt AC 69 ms 12672 KB
20_14.txt AC 73 ms 12800 KB
20_15.txt AC 66 ms 13304 KB
20_16.txt AC 66 ms 13560 KB