Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
  int n,m,q;
  cin >> n >> m >> q;
  vi a(q),b(q),c(q),d(q);
  REP(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  vi x(n,-1);
  ll ans=0;
  REP(i,(1<<m)) {
    ll temp=0;
    bool flg=true;
    vpi ch;
    REP(j,m) {
      if(((i>>j)&1)==1) {
        for(int k=a[j]-1;k>=0;k--) {
          if(x[k]!=-1) {
            x[a[j]-1]=x[k];
          } else {
            x[a[j]-1]=1;
          }
        }
        pi che(a[j]-1,b[j]-1);
        if(find(ALL(ch),che)!=ch.end()) {
          flg=false;
          break;
        }
        if(x[b[j]-1]!=-1) {
          x[b[j]-1]
        }
        ch.emplace_back(che);
        x[b[j]-1]=x[a[j]-1]+c[j];
        temp+=d[j];
      }
    }
    int check=1;
    REP(j,n) {
      if(x[j]==-1) break;
      if(x[j]>=check) {
        check=x[j];
      } else {
        flg=false;
      }
    }
    if(flg) {
      cout << 
      ans=max(ans,temp);
    }
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:74:20: error: expected ';' before '}' token
   74 |           x[b[j]-1]
      |                    ^
      |                    ;
   75 |         }
      |         ~           
a.cc:74:19: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   74 |           x[b[j]-1]
      |                   ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: declared here
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
a.cc:92:23: error: no match for 'operator=' (operand types are 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} and 'const long long int')
   92 |       ans=max(ans,temp);
      |                       ^
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:458:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator=(std::basic_ostream<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]'
  458 |       operator=(basic_ostream&& __rhs)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:458:33: note:   no known conversion for argument 1 from 'const long long int' to 'std::basic_ostream<char>&&'
  458 |       operator=(basic_ostream&& __rhs)
      |                 ~~~~~~~~~~~~~~~~^~~~~