Language: C++

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;

#define mod 1000000007

int main()
{
    int r, c, n;
    cin >> r >> c >> n;
    vector<pair<int, int> > retsu(100001), gyou(100001);
    for(int i = 0; i < n; i++){
        int rr, cc, a;
        cin >> rr >> cc >> a;
        retsu[rr].push_back(make_pair(cc, a));
        gyou[cc].push_back(make_pair(rr, a));
    }
    double retsusub = mod + 0.0, gyousub = mod + 0.0, retsufirst[10001], gyoufirst[10001];
    for(int i = 1; i <= r; i++){
        retsufirst[i] = mod;
        if(retsu[i].size() == 0) continue;
        sort(retsu[i].begin(), retsu[i].end());
        for(int j = 1; j < retsu[i].size(); j++){
            double tmp = (double)(retsu[i][j].second - retsu[i][j - 1].second) / (retsu[i][j].first - retsu[i][j - 1].first);
            if(retsusub == mod){
                retsusub = tmp;
                
            }
            if(retsusub != tmp || floor(retsusub) != retsusub){
                cout << "No" << endl;
                return 0;
            }
        }
        if(retsusub != mod){
            retsufirst[i] = retsu[i][0].second - (retsusub * (retsu[i][0].first - 1));
            if(retsufirst[i] + retsusub * (r - 1) < 0){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    for(int i = 1; i <= c; i++){
        // cout << i << endl;
        gyoufirst[i] = mod;
        if(gyou[i].size() == 0) continue;
        sort(gyou[i].begin(), gyou[i].end());
        for(int j = 1; j < gyou[i].size(); j++){
            double tmp = (double)(gyou[i][j].second - gyou[i][j - 1].second) / (gyou[i][j].first - gyou[i][j - 1].first);
            // cout << tmp << endl;
            if(gyousub == mod){
                // cout << "ho" << endl;
                gyousub = tmp;
            }
            // cout << gyousub << endl;
            if(gyousub != tmp || floor(gyousub) != gyousub){
                cout << "No" << endl;
                return 0;
            }
        }
        if(retsusub != mod){
            gyoufirst[i] = gyou[i][0].second - (gyousub * (gyou[i][0].first - 1));
            if(gyoufirst[i] + gyousub * (c - 1) < 0){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    // cout << retsusub << " " << gyousub << endl;
    // cout << gyoufirst << " " << retsufirst << endl;
    if(gyoufirst[1] != mod && retsufirst[1] != mod && gyoufirst[1] != retsufirst[1]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:19: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'push_back'
   31 |         retsu[rr].push_back(make_pair(cc, a));
      |                   ^~~~~~~~~
a.cc:32:18: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'push_back'
   32 |         gyou[cc].push_back(make_pair(rr, a));
      |                  ^~~~~~~~~
a.cc:37:21: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'size'
   37 |         if(retsu[i].size() == 0) continue;
      |                     ^~~~
a.cc:38:23: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'begin'
   38 |         sort(retsu[i].begin(), retsu[i].end());
      |                       ^~~~~
a.cc:38:41: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'end'
   38 |         sort(retsu[i].begin(), retsu[i].end());
      |                                         ^~~
a.cc:39:37: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'size'
   39 |         for(int j = 1; j < retsu[i].size(); j++){
      |                                     ^~~~
a.cc:40:43: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   40 |             double tmp = (double)(retsu[i][j].second - retsu[i][j - 1].second) / (retsu[i][j].first - retsu[i][j - 1].first);
      |                                           ^
a.cc:40:64: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   40 |             double tmp = (double)(retsu[i][j].second - retsu[i][j - 1].second) / (retsu[i][j].first - retsu[i][j - 1].first);
      |                                                                ^
a.cc:40:91: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   40 |             double tmp = (double)(retsu[i][j].second - retsu[i][j - 1].second) / (retsu[i][j].first - retsu[i][j - 1].first);
      |                                                                                           ^
a.cc:40:111: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   40 |             double tmp = (double)(retsu[i][j].second - retsu[i][j - 1].second) / (retsu[i][j].first - retsu[i][j - 1].first);
      |                                                                                                               ^
a.cc:51:37: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   51 |             retsufirst[i] = retsu[i][0].second - (retsusub * (retsu[i][0].first - 1));
      |                                     ^
a.cc:51:71: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   51 |             retsufirst[i] = retsu[i][0].second - (retsusub * (retsu[i][0].first - 1));
      |                                                                       ^
a.cc:61:20: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'size'
   61 |         if(gyou[i].size() == 0) continue;
      |                    ^~~~
a.cc:62:22: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'begin'
   62 |         sort(gyou[i].begin(), gyou[i].end());
      |                      ^~~~~
a.cc:62:39: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'end'
   62 |         sort(gyou[i].begin(), gyou[i].end());
      |                                       ^~~
a.cc:63:36: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'size'
   63 |         for(int j = 1; j < gyou[i].size(); j++){
      |                                    ^~~~
a.cc:64:42: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   64 |             double tmp = (double)(gyou[i][j].second - gyou[i][j - 1].second) / (gyou[i][j].first - gyou[i][j - 1].first);
      |                                          ^
a.cc:64:62: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   64 |             double tmp = (double)(gyou[i][j].second - gyou[i][j - 1].second) / (gyou[i][j].first - gyou[i][j - 1].first);
      |                                                              ^
a.cc:64:88: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   64 |             double tmp = (double)(gyou[i][j].second - gyou[i][j - 1].second) / (gyou[i][j].first - gyou[i][j - 1].first);
      |                                                                                        ^
a.cc:64:107: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   64 |             double tmp = (double)(gyou[i][j].second - gyou[i][j - 1].second) / (gyou[i][j].first - gyou[i][j - 1].first);
      |                                                                                                           ^
a.cc:77:35: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   77 |             gyoufirst[i] = gyou[i][0].second - (gyousub * (gyou[i][0].first - 1));
      |                                   ^
a.cc:77:67: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   77 |             gyoufirst[i] = gyou[i][0].second - (gyousub * (gyou[i][0].first - 1));
      |                                                                   ^