Language: C++

#include <cstdio>
#include <cmath>

#include <algorithm>
#include <utility>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int R, C, n;

std::vector< std::pair<int, int> > vec[100000];

bool solve() {
	inc(i, C - 1) {
		std::vector< std::pair<int, int> > v2;
		for(auto && e : vec[i + 0]) { v2.push_back(std::make_pair(e.first * 2 + 0, e.second)); }
		for(auto && e : vec[i + 1]) { v2.push_back(std::make_pair(e.first * 2 + 1, e.second)); }
		std::sort(v2.begin(), v2.end());
		
		int size = v2.size();
		bool flag = false;
		int diff;
		inc(j, size) {
			int fi = v2[j].first;
			if(j != size - 1 && fi % 2 == 0 && fi + 1 == v2[j + 1].first) {
				if(! flag) {
					diff = v2[j].second - v2[j + 1].second;
					flag = true;
				} else {
					if(diff != v2[j].second - v2[j + 1].second) { return false; }
				}
			}
		}
		
		inc(j, size) {
			int fi = v2[j].first;
			int se = v2[j].second;
			if( (fi % 2 == 0 && se >= diff) || (fi % 2 == 1 && se >= -diff) ) { } else { return false; }
		}
	}
	
	return true;
}

int main() {
	scanf("%d%d%d", &R, &C, &n);
	inc(i, n) {
		int r, c, a;
		scanf("%d%d%d", &r, &c, &a);
		r--; c--;
		vec[c].push_back(std::make_pair(c, a));
	}
	
	inc(i, C) { std::sort(vec[i].begin(), vec[i].end()); }
	

	
	printf("%s\n", solve() ? "Yes" : "No");
	
	return 0;
}


Compiler output:
a.cc:35:6: error: 'vector' in namespace 'std' does not name a template type
   35 | std::vector< std::pair<int, int> > vec[100000];
      |      ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    5 | #include <utility>
  +++ |+#include <vector>
    6 | 
a.cc: In function 'bool solve()':
a.cc:39:22: error: 'vector' is not a member of 'std'
   39 |                 std::vector< std::pair<int, int> > v2;
      |                      ^~~~~~
a.cc:39:22: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:39:50: error: expected primary-expression before '>' token
   39 |                 std::vector< std::pair<int, int> > v2;
      |                                                  ^
a.cc:39:52: error: 'v2' was not declared in this scope
   39 |                 std::vector< std::pair<int, int> > v2;
      |                                                    ^~
a.cc:40:33: error: 'vec' was not declared in this scope; did you mean 'dec'?
   40 |                 for(auto && e : vec[i + 0]) { v2.push_back(std::make_pair(e.first * 2 + 0, e.second)); }
      |                                 ^~~
      |                                 dec
a.cc:41:33: error: 'vec' was not declared in this scope; did you mean 'dec'?
   41 |                 for(auto && e : vec[i + 1]) { v2.push_back(std::make_pair(e.first * 2 + 1, e.second)); }
      |                                 ^~~
      |                                 dec
a.cc: In function 'int main()':
a.cc:75:17: error: 'vec' was not declared in this scope; did you mean 'dec'?
   75 |                 vec[c].push_back(std::make_pair(c, a));
      |                 ^~~
      |                 dec
a.cc:78:31: error: 'vec' was not declared in this scope; did you mean 'dec'?
   78 |         inc(i, C) { std::sort(vec[i].begin(), vec[i].end()); }
      |                               ^~~
      |                               dec