Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

struct edge {
    int to, cost;
};

int V;
vector<edge> G[1000000];
ll d[3000][3000];
int v[200000], d[200000], c[200000];

void bfs(int n) {
    fill(d[n], d[n] + 3000, inf);
    queue<pii> que;
    que.push(pii(n, 0));
    d[n][n] = 0;
    while (!que.empty()) {
        pii p = que.front();
        que.pop();
        int num = p.first;
        int len = G[num].size();
        for (int i = 0; i < len; i++) {
            if (d[n][G[num][i].to] == inf) {
                d[n][G[num][i].to] = p.second + 1;
                que.push(pii(G[num][i].to, p.second + 1));
            }
        }
    }
}

int color[200000];

int main() {
    int N, M;
    cin >> N;
    V = N;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        edge e1;
        e1.to = b;
        e1.cost = 1;
        G[a].push_back(e1);
        edge e2;
        e2.to = a;
        e2.cost = 1;
        G[b].push_back(e1);
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        cin >> v[i] >> d[i] >> c[i];
    }
    for (int i = 0; i < N; i++) {
        bfs(i);
    }
    fill(color, color + N, 0);
    for (int i = Q - 1; i >= 0; i++) {
        for (int j = 0; j < N; j++) {
            if (color[j] == 0) {
                if (d[j][v[i] - 1] <= d[i]) {
                    color[j] = c[i];
                }
            }
        }
    }
    for (int i = 0; i < N; i++) {
        cout << color[i] << endl;
    }
}


Compiler output:
a.cc:40:16: error: conflicting declaration 'int d [200000]'
   40 | int v[200000], d[200000], c[200000];
      |                ^
a.cc:39:4: note: previous declaration as 'll d [3000][3000]'
   39 | ll d[3000][3000];
      |    ^
a.cc: In function 'int main()':
a.cc:82:21: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'll [3000]' {aka 'long long int [3000]'})
   82 |         cin >> v[i] >> d[i] >> c[i];
      |         ~~~~~~~~~~~ ^~ ~~~~
      |             |             |
      |             |             ll [3000] {aka long long int [3000]}
      |             std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
                 from a.cc:2:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  170 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:170:7: note:   conversion of argument 1 would be ill-formed:
a.cc:82:27: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'll*' {aka 'long long int*'}
   82 |         cin >> v[i] >> d[i] >> c[i];
      |                        ~~~^
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  174 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:174:7: note:   conversion of argument 1 would be ill-formed:
a.cc:82:27: error: invalid conversion from 'll*' {aka 'long long int*'} to 'short int' [-fpermissive]
   82 |         cin >> v[i] >> d[i] >> c[i];
      |                        ~~~^
      |                           |
      |                           ll* {aka long long int*}
a.cc:82:27: error: cannot bind rvalue '(short int)((ll*)(& d[i]))' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  177 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:177:7: note:   conversion of argument 1 would be ill-formed:
a.cc:82:27: error: invalid conversion from 'll*' {aka 'long long int*'} to 'short unsigned int' [-fpermissive]
   82 |         cin >> v[i] >> d[i] >> c[i];
      |                        ~~~^
      |                           |
      |                           ll* {aka long long int*}
a.cc:82:27: error: cannot bind rvalue '(short unsigned int)((ll*)(& d[i]))' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  181 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:181:7: note:   conversion of argument 1 would be ill-formed:
a.cc:82:27: error: invalid conversion from 'll*' {aka 'long long int*'} to 'int' [-fpermissive]
   82 |         cin >> v[i] >> d[i] >> c[i];
      |                        ~~~^
      |                           |
      |                           ll* {aka long long int*}
a.cc:82:27: error: cannot bind rvalue '(int)((ll*)(& d[i]))' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:184:7: note:   conversion of argument 1 would be ill-formed:
a.cc:82:27: error: invalid conversion from 'll*' {aka 'long long int*'} to 'unsigned int' [-fpermissive]
   82 |         cin >> v[i] >> d[i] >> c[i];
      |                        ~~~^
      |                           |
      |                           ll* {aka long long int*}
a.cc:82:27: error: cannot bind rvalue '(unsigned int)((ll*)(& d[i]))' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:188:7: note:   conversion of argument 1 would be ill-formed:
a.cc:82:27: error: invalid conversion from 'll*' {aka 'long long int*'} to 'long int' [-fpermissive]
   82 |         cin >> v[i] >> d[i] >> c[i];
      |                        ~~~^
      |                           |
      |                           ll* {aka long long int*}
a.cc:82:27: error: cannot bind rvalue '(long int)((ll*)(& d[i]))' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:192:7: note:   conversion of argument 1 would be ill-formed:
a.cc:82:27: error: invalid conversion from 'll*' {aka 'long long int*'} to 'long unsigned int' [-fpermissive]
   82 |         cin >> v[i] >> d[i] >> c[i];
      |                        ~~~^
      |                           |
      |                           ll* {aka long long int*}
a.cc:82:27: error: cannot bind rvalue '(long unsigned int)((ll*)(& d[i]))' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  199 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:199:7: note:   conversion of argument 1 would be ill-formed:
a.cc:82:27: error: invalid conversion from 'll*' {aka 'long long int*'} to 'long long int' [-fpermissive]
   82 |         cin >> v[i] >> d[i] >> c[i];
      |                        ~~~^
      |                           |
      |                           ll* {aka long long int*}
a.cc:82:27: error: cannot bind rvalue '(long long int)((ll*)(& d[i]))' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  203 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:203:7: note:   conversion of argument 1 would be ill-formed:
a.cc:82:27: error: invalid conversion from 'll*' {aka 'long long int*'} to 'long long unsigned int' [-fpermissive]
   82 |         cin >> v[i] >> d[i] >> c[i];
      |                        ~~~^
      |                           |
      |                           ll* {aka long long int*}
a.cc:82:27: error: cannot bind rvalue '(long long unsigned int)((ll*)(& d[i]))' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  328 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/14/istream:328:7: note:   conversion of argument 1 would be ill-formed:
a.cc:82:27: error: cannot bind non-const lvalue reference of type 'void*&' to an rvalue of type 'void*'
   82 |         cin >> v[i] >> d[i] >> c[i];
      |                        ~~~^
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
  219 |       operator>>(float& __f)
      |       ^~~~~~~~
/usr/include/c++/14/istream:219:25: note:   no known conversion for argument 1 from 'll [3000]' {aka 'long long int [3000]'} to 'float&'
  219 |       operator>>(float& __f)
      |                  ~~~~~~~^~~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
  223 |       operator>>(double& __f)
      |       ^~~~~~~~
/usr/include/c++/14/istream:223:26: note:   no known conversion for argument 1 from 'll [3000]' {aka 'long long int [3000]'} to 'double&'
  223 |       operator>>(double& __f)
      |                  ~~~~~~~~^~~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
  227 |       operator>>(long double& __f)
      |       ^~~~~~~~
/usr/include/c++/14/istream:227:31: note:   no known conversion for argument 1 from 'll [3000]' {aka 'long long int [3000]'} to 'long double&'
  227 |       operator>>(long double& __f)
      |                  ~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits =