Language: C++

#include <iostream>
#include <math.h>

bool DFSUtil(int, vector<bool>);

int main(){
  int R, C;
  cin >> R >> C;
  int N;
  cin >> N;
  vector<int, pair<int, int>> g;
  
  for(int i = 0; i < N; i++){
    int r, c, a;
    cin >> r >> c >> a;
    g[r].push_back(make_pair( c + C, a);
    g[c + C].push_back(make_pair(r, a));
  }

  vector<bool> visited(R + C, false);
  vector<int> node(R + C, 0);
  int minR, minC = pow(10,9);
  if(!DFSUtil(0, visited)){
    cout << "No";
  }
  else{
    cout >> "Yes";
  }
}

bool DFSUtil(int v, vector<bool> visited){
  visited[v] = true;
  for(int i = 0; i < g[v].size(); i++){
    int w = g[v][i]. first;
    int a = g[v][i].second;
    if(visited[w] && node[v] + node[w] != a){
      return false;
    }
    node[w] = a - node[v];

    if(v < R) minR = minR >node[v] ? node[v] : minR;
    if(v >= R) minC = minC>node[v] ? node[v] : minC;
    if(minR + minC < 0) return false;
    if(!visited[w]){
      if(!DFSUtil(w, visited)) return false;
    }
  }
  return true;
}


Compiler output:
a.cc:4:19: error: 'vector' has not been declared
    4 | bool DFSUtil(int, vector<bool>);
      |                   ^~~~~~
a.cc:4:25: error: expected ',' or '...' before '<' token
    4 | bool DFSUtil(int, vector<bool>);
      |                         ^
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |   cin >> R >> C;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:11:3: error: 'vector' was not declared in this scope
   11 |   vector<int, pair<int, int>> g;
      |   ^~~~~~
a.cc:11:10: error: expected primary-expression before 'int'
   11 |   vector<int, pair<int, int>> g;
      |          ^~~
a.cc:16:5: error: 'g' was not declared in this scope
   16 |     g[r].push_back(make_pair( c + C, a);
      |     ^
a.cc:16:20: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   16 |     g[r].push_back(make_pair( c + C, a);
      |                    ^~~~~~~~~
      |                    std::make_pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
a.cc:20:10: error: expected primary-expression before 'bool'
   20 |   vector<bool> visited(R + C, false);
      |          ^~~~
a.cc:21:10: error: expected primary-expression before 'int'
   21 |   vector<int> node(R + C, 0);
      |          ^~~
a.cc:23:18: error: 'visited' was not declared in this scope
   23 |   if(!DFSUtil(0, visited)){
      |                  ^~~~~~~
a.cc:24:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   24 |     cout << "No";
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:27:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   27 |     cout >> "Yes";
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc: At global scope:
a.cc:31:21: error: 'vector' has not been declared
   31 | bool DFSUtil(int v, vector<bool> visited){
      |                     ^~~~~~
a.cc:31:27: error: expected ',' or '...' before '<' token
   31 | bool DFSUtil(int v, vector<bool> visited){
      |                           ^
a.cc: In function 'bool DFSUtil(int, int)':
a.cc:32:3: error: 'visited' was not declared in this scope
   32 |   visited[v] = true;
      |   ^~~~~~~
a.cc:33:22: error: 'g' was not declared in this scope
   33 |   for(int i = 0; i < g[v].size(); i++){
      |                      ^
a.cc:36:22: error: 'node' was not declared in this scope
   36 |     if(visited[w] && node[v] + node[w] != a){
      |                      ^~~~
a.cc:39:5: error: 'node' was not declared in this scope
   39 |     node[w] = a - node[v];
      |     ^~~~
a.cc:41:12: error: 'R' was not declared in this scope
   41 |     if(v < R) minR = minR >node[v] ? node[v] : minR;
      |            ^
a.cc:41:15: error: 'minR' was not declared in this scope
   41 |     if(v < R) minR = minR >node[v] ? node[v] : minR;
      |               ^~~~
a.cc:42:13: error: 'R' was not declared in this scope
   42 |     if(v >= R) minC = minC>node[v] ? node[v] : minC;
      |             ^
a.cc:42:16: error: 'minC' was not declared in this scope
   42 |     if(v >= R) minC = minC>node[v] ? node[v] : minC;
      |                ^~~~
a.cc:43:8: error: 'minR' was not declared in this scope
   43 |     if(minR + minC < 0) return false;
      |        ^~~~
a.cc:43:15: error: 'minC' was not declared in this scope
   43 |     if(minR + minC < 0) return false;
      |               ^~~~