Language: C++

#include<iostream>
using namespace std;

int main(void){
    int R;
    int C;
    int N;
    string res = "Yes";
    // input
    cin >> R;
    cin >> C;
    cin >> N;
    
    for (i=1; i<=N; i++) {
        cin >> r[i-1];
        cin >> c[i-1];
        cin >> a[i-1];
    } 
    
    //initialize
    vector<int> rr(N);
    vector<int> cc(N);
    vector<int> aa(N);
    vector<int> rca_flag(N, 1);
    vector<int> r_vec(R, 0);
    vector<int> c_vec(C, 0);
    vector<int> r_vec_flag(R, 0);
    vector<int> c_vec_flag(C, 0);
    int go_flg = 1;
    
    
    
    while (go_flg == 1){
        // find first
        for (i=1; i<=N; i++){
            if (rca_flag[i-1] == 1){
                // initailize
                rca_flag[i-1] = 0;
                r = rr[i-1];
                c = cc[i-1];
                a = aa[i-1];
                r_vec[i-1] = a;
                r_vec_flag[r-1] = 1;
                c_vec[i-1] = 0;
                c_vec_flag[c-1] = 1;
                break;
            }
            if (i == N){
                go_flg = 0;
            }             
        }
        while (go_flg == 1){
            for (i==1; i<=N; i++){
                if (rca_flag[i-1] == 1){
                    rca_flag[i-1] = 0;
                    r = rr[i-1];
                    c = cc[i-1];
                    a = aa[i-1];
                    if ((r_vec_flag[r-1] == 1) && (c_vec_flag[c-1] == 1)){
                        if (a != r_vec[r-1] + c_vec[c-1]){
                            res = "No";
                            go_flg = 0;
                        }
                    } else if (r_vec_flag[r-1] == 1){
                        c_vec_flag[c-1] = 1;
                        c_vec[c-1] = a - r_vec[r-1];
                    } else if (c_vec_flag[c-1] == 1){
                        r_vec_flag[r-1] = 1;
                        r_vec[r-1] = a - c_vec[c-1];
                    } 
                }
            }
        }
    }
    

    cout << res << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'i' was not declared in this scope
   14 |     for (i=1; i<=N; i++) {
      |          ^
a.cc:15:16: error: 'r' was not declared in this scope
   15 |         cin >> r[i-1];
      |                ^
a.cc:16:16: error: 'c' was not declared in this scope
   16 |         cin >> c[i-1];
      |                ^
a.cc:17:16: error: 'a' was not declared in this scope
   17 |         cin >> a[i-1];
      |                ^
a.cc:21:5: error: 'vector' was not declared in this scope
   21 |     vector<int> rr(N);
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:21:12: error: expected primary-expression before 'int'
   21 |     vector<int> rr(N);
      |            ^~~
a.cc:22:12: error: expected primary-expression before 'int'
   22 |     vector<int> cc(N);
      |            ^~~
a.cc:23:12: error: expected primary-expression before 'int'
   23 |     vector<int> aa(N);
      |            ^~~
a.cc:24:12: error: expected primary-expression before 'int'
   24 |     vector<int> rca_flag(N, 1);
      |            ^~~
a.cc:25:12: error: expected primary-expression before 'int'
   25 |     vector<int> r_vec(R, 0);
      |            ^~~
a.cc:26:12: error: expected primary-expression before 'int'
   26 |     vector<int> c_vec(C, 0);
      |            ^~~
a.cc:27:12: error: expected primary-expression before 'int'
   27 |     vector<int> r_vec_flag(R, 0);
      |            ^~~
a.cc:28:12: error: expected primary-expression before 'int'
   28 |     vector<int> c_vec_flag(C, 0);
      |            ^~~
a.cc:35:14: error: 'i' was not declared in this scope
   35 |         for (i=1; i<=N; i++){
      |              ^
a.cc:36:17: error: 'rca_flag' was not declared in this scope
   36 |             if (rca_flag[i-1] == 1){
      |                 ^~~~~~~~
a.cc:39:17: error: 'r' was not declared in this scope
   39 |                 r = rr[i-1];
      |                 ^
a.cc:39:21: error: 'rr' was not declared in this scope
   39 |                 r = rr[i-1];
      |                     ^~
a.cc:40:17: error: 'c' was not declared in this scope
   40 |                 c = cc[i-1];
      |                 ^
a.cc:40:21: error: 'cc' was not declared in this scope
   40 |                 c = cc[i-1];
      |                     ^~
a.cc:41:17: error: 'a' was not declared in this scope
   41 |                 a = aa[i-1];
      |                 ^
a.cc:41:21: error: 'aa' was not declared in this scope
   41 |                 a = aa[i-1];
      |                     ^~
a.cc:42:17: error: 'r_vec' was not declared in this scope
   42 |                 r_vec[i-1] = a;
      |                 ^~~~~
a.cc:43:17: error: 'r_vec_flag' was not declared in this scope
   43 |                 r_vec_flag[r-1] = 1;
      |                 ^~~~~~~~~~
a.cc:44:17: error: 'c_vec' was not declared in this scope
   44 |                 c_vec[i-1] = 0;
      |                 ^~~~~
a.cc:45:17: error: 'c_vec_flag' was not declared in this scope
   45 |                 c_vec_flag[c-1] = 1;
      |                 ^~~~~~~~~~
a.cc:53:18: error: 'i' was not declared in this scope
   53 |             for (i==1; i<=N; i++){
      |                  ^
a.cc:54:21: error: 'rca_flag' was not declared in this scope
   54 |                 if (rca_flag[i-1] == 1){
      |                     ^~~~~~~~
a.cc:56:21: error: 'r' was not declared in this scope
   56 |                     r = rr[i-1];
      |                     ^
a.cc:56:25: error: 'rr' was not declared in this scope
   56 |                     r = rr[i-1];
      |                         ^~
a.cc:57:21: error: 'c' was not declared in this scope
   57 |                     c = cc[i-1];
      |                     ^
a.cc:57:25: error: 'cc' was not declared in this scope
   57 |                     c = cc[i-1];
      |                         ^~
a.cc:58:21: error: 'a' was not declared in this scope
   58 |                     a = aa[i-1];
      |                     ^
a.cc:58:25: error: 'aa' was not declared in this scope
   58 |                     a = aa[i-1];
      |                         ^~
a.cc:59:26: error: 'r_vec_flag' was not declared in this scope
   59 |                     if ((r_vec_flag[r-1] == 1) && (c_vec_flag[c-1] == 1)){
      |                          ^~~~~~~~~~
a.cc:59:52: error: 'c_vec_flag' was not declared in this scope
   59 |                     if ((r_vec_flag[r-1] == 1) && (c_vec_flag[c-1] == 1)){
      |                                                    ^~~~~~~~~~
a.cc:60:34: error: 'r_vec' was not declared in this scope
   60 |                         if (a != r_vec[r-1] + c_vec[c-1]){
      |                                  ^~~~~
a.cc:60:47: error: 'c_vec' was not declared in this scope
   60 |                         if (a != r_vec[r-1] + c_vec[c-1]){
      |                                               ^~~~~
a.cc:66:25: error: 'c_vec' was not declared in this scope
   66 |                         c_vec[c-1] = a - r_vec[r-1];
      |                         ^~~~~
a.cc:66:42: error: 'r_vec' was not declared in this scope
   66 |                         c_vec[c-1] = a - r_vec[r-1];
      |                                          ^~~~~
a.cc:69:25: error: 'r_vec' was not declared in this scope
   69 |                         r_vec[r-1] = a - c_vec[c-1];
      |                         ^~~~~
a.cc:69:42: error: 'c_vec' was not declared in this scope
   69 |                         r_vec[r-1] = a - c_vec[c-1];
      |                                          ^~~~~