Language: C++

#include<bits/stdc++.h>
using namespace std;

using ll = long long;

const int MAXN = 1010;
int N;
ll dist[MAXN][MAXN];
int ccNum[MAXN];
vector<int> ccs[MAXN];

const int MAXM = 2020;
int M;
pair<ll, pair<int, int>> edges[MAXM];
ll X;

const int MOD = int(1e9)+7;

int main() {
  cin >> N >> M >> X;
  for (int e = 0; e < M; e++) {
    int u, v, w; cin >> u >> v >> w; u--, v--;
    edges[e] = {w,{u,v}};
  }
  sort(edges,edges+M);
  for (int i = 0; i < N; i++) { ccs[ccNum[i] = i].push_back(i); }
  for (int e = 0; e < M; e++) {
    int u = ccNum[edges[e].second.first], v = ccNum[edges[e].second.second];
    if (u==v) continue;
    for (int a : cc[u]) for (int b : cc[v]) dist[a][b] = dist[b][a] = edges[e].first;
    for (int b : cc[v]) { ccs[ccNum[b] = u].push_back(b); }
  }
  ll c0 = 0, c1 = 0;
  for (int e = 0; e < M; e++) {
    ll v = edges[e].first - dist[edges[e].second.first][edges[e].second.second];
    c0 += (v < X); c1 += (v <= X);
  }
  c0 = max(c0-1, 0), c1 = max(c1-1, 0);
  int v0 = 1, v1 = 1;
  for (int i = 0; i < M-c0;i++) { v0 <<= 1; if (v0 >= MOD) v0 -= MOD; }
  for (int i = 0; i < M-c1;i++) { v1 <<= 1; if (v1 >= MOD) v1 -= MOD; }
  int ans = v0 - v1; if (ans < 0) ans += MOD;
  cout << ans << '\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:18: error: 'cc' was not declared in this scope; did you mean 'ccs'?
   30 |     for (int a : cc[u]) for (int b : cc[v]) dist[a][b] = dist[b][a] = edges[e].first;
      |                  ^~
      |                  ccs
a.cc:31:18: error: 'cc' was not declared in this scope; did you mean 'ccs'?
   31 |     for (int b : cc[v]) { ccs[ccNum[b] = u].push_back(b); }
      |                  ^~
      |                  ccs
a.cc:38:11: error: no matching function for call to 'max(ll, int)'
   38 |   c0 = max(c0-1, 0), c1 = max(c1-1, 0);
      |        ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:38:11: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   38 |   c0 = max(c0-1, 0), c1 = max(c1-1, 0);
      |        ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:38:11: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   38 |   c0 = max(c0-1, 0), c1 = max(c1-1, 0);
      |        ~~~^~~~~~~~~
a.cc:38:30: error: no matching function for call to 'max(ll, int)'
   38 |   c0 = max(c0-1, 0), c1 = max(c1-1, 0);
      |                           ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:38:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   38 |   c0 = max(c0-1, 0), c1 = max(c1-1, 0);
      |                           ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:38:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   38 |   c0 = max(c0-1, 0), c1 = max(c1-1, 0);
      |                           ~~~^~~~~~~~~