Language: C++

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

#define pb                push_back
#define mp                make_pair
#define all(x)            (x).begin(),(x).end()
#define fi                first
#define se                second
#define vc                vector
#define pii               pair<ll,ll>
#define endl              "\n"
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define repe(i,a,b)       for(ll i=a;i<=b;i++)
#define bac(i,a,b)        for(ll i=a;i>b;i--)
#define bace(i,a,b)       for(ll i=a;i>=b;i--)
#define fast              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll                long long int
#define ld                long double
#define mod1              (ll)(1e9 + (ll)7)
#define mod2              (ll)998244353
#define pi                (float)3.14159265358979323846
#define inf               LLONG_MAX
#define ninf              LLONG_MIN

#define DECIMAL(n)        std::cout << std::fixed << std::setprecision(n)
#define SORT(v)           sort(all(v))
#define RSORT(v)          sort(all(v),greater<ll>())
#define REVERSE(v)        reverse(all(v))

#define pow(i,n)          (ll)pow((ll)i,n)
#define pow2(n)           ((ll)1<<n)
#define sz(x)             (ll)x.size()

typedef std::priority_queue<ll, std::vector<ll>, std::greater<ll> > min_pq;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

inline string inttos(ll a){std::stringstream soso; soso<<a; return soso.str();}
inline ll stoint(const std::string &s) {std::stringstream soso; soso << s; long long x; soso >> x; return x;}
inline std::string inttobin(ll x) {return std::bitset<7>(x).to_string();}
inline void swp(ll &a, ll &b){auto temp=a;a=b;b=temp;}

//pri - 1000000009
//ba  - 937,991,1013,1409,1741,4391

bool isvalid(auto x, vc<ll> v, set<pii> done, ll m){
    ll one = x.fi.fi;
    ll two = x.fi.se;
    if(done.find({one,two})!=done.end())
        return false;
    if(v[one]!=-1 && v[two]!=1){
        if(v[one] - v[two] == x.se.fi)
            return true;
        else
            return false;
    }
    if(v[one]==-1 && v[two]==-1)
        return true;
    
    if(v[one]==-1){
        if(v[two])
    }
    
    if(v[two]==-1){
        
    }
    
}

void backtrack(map<pii,pii> ma,vc<ll> v,set<pii> done,ll m){
    for(auto x: ma){
        if(isvalid(x,v,done,m)){
            
        }
    }
}

void solve(){
    ll n,m,q;
    cin>>n>>m>>q;
    multimap<pii,pii> ma;
    rep(i,0,q){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        pii x = {a,b};
        pii y= {c,d};
        ma.insert({x,y});
    }
    vc<ll> v(n,-1);
    set<pii> s;
    backtrack(ma,v,s,m);

}


signed main(){
    fast
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
    #endif
    ll t=1;
    //cin>>t;
    rep(i,0,t){
       solve();
    }

}


Compiler output:
a.cc:55:14: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   55 | bool isvalid(auto x, vc<ll> v, set<pii> done, ll m){
      |              ^~~~
a.cc: In function 'bool isvalid(auto:28, std::vector<long long int>, std::set<std::pair<long long int, long long int> >, long long int)':
a.cc:71:5: error: expected primary-expression before '}' token
   71 |     }
      |     ^
a.cc: In function 'void solve()':
a.cc:100:15: error: could not convert 'ma' from 'std::multimap<std::pair<long long int, long long int>, std::pair<long long int, long long int> >' to 'std::map<std::pair<long long int, long long int>, std::pair<long long int, long long int> >'
  100 |     backtrack(ma,v,s,m);
      |               ^~
      |               |
      |               std::multimap<std::pair<long long int, long long int>, std::pair<long long int, long long int> >
a.cc: In function 'bool isvalid(auto:28, std::vector<long long int>, std::set<std::pair<long long int, long long int> >, long long int) [with auto:28 = std::pair<const std::pair<long long int, long long int>, std::pair<long long int, long long int> >]':
a.cc:77:1: warning: control reaches end of non-void function [-Wreturn-type]
   77 | }
      | ^