Language: C++

#include <iostream>
using namespace std;

int R, C, N;
int r[100000], c[100000], a[100000];
int field[100000][100000];
bool filled[100000][100000];

const int dx[] = {1, 1, -1, -1};
const int dy[] = {1, -1, 1, -1};

bool isIllegal(int i) {
    int ri = r[i];
    int ci = c[i];
    int ai = a[i];

    for (int j = 0; j < 4; j++) {
        int y = ri + dy[j];
        int x = ci + dx[j];
        if (x < 0 || C <= x || y < 0 || R <= y) continue;

        int cnt = 1 + filled[ri][x] + filled[y][ci] + filled[y][x];
        if (cnt <= 2) continue;
        if (cnt == 4) {
            if (ai + field[y][x] != field[ri][x] + field[y][ci]) {
                return true;
            }
        } else if (!filled[ri][x]) {
            int temp = ai + field[y][x] - field[y][ci];
            if (temp < 0) return true;
            field[ri][x] = temp;
            filled[ri][x] = true;
        } else if (!filled[y][ci]) {
            int temp = ai + field[y][x] - field[ri][x];
            if (temp < 0) return true;
            field[y][ci] = temp;
            filled[y][ci] = true;
        } else if (!filled[y][x]) {
            int temp = field[ri][x] + field[y][ci] - ai;
            if (temp < 0) return true;
            field[y][x] = temp;
            filled[y][x] = true;
        }
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> R >> C >> N;
    for (int i = 0; i < N; i++) {
        cin >> r[i] >> c[i] >> a[i];
        r[i]--;
        c[i]--;
        field[r[i]][c[i]] = a[i];
        filled[r[i]][c[i]] = true;
    }

    for (int i = 0; i < N; i++) {
        if (isIllegal(i)) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Compiler output:
/tmp/ccyafRfv.o: in function `isIllegal(int)':
a.cc:(.text+0xe9): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o
a.cc:(.text+0x111): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o
a.cc:(.text+0x138): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o
a.cc:(.text+0x205): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o
a.cc:(.text+0x2c7): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o
a.cc:(.text+0x2ee): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o
a.cc:(.text+0x3b0): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o
a.cc:(.text+0x3d7): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o
a.cc:(.text+0x491): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o
/tmp/ccyafRfv.o: in function `main':
a.cc:(.text+0x6a7): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o
collect2: error: ld returned 1 exit status