Cod sursă (job #547480)

Utilizator avatar VictorC Miyuki Akihiro VictorC IP ascuns
Problemă Lanterna Compilator cpp | 0,46 kb
Rundă lasm_19_03_2020_10 Status evaluat
Dată 19 mar. 2020 21:24:10 Scor 0
#include <bits/stdc++.h>
using namespace std;
int N, M, K, x, y;
int A[500005], B[500005];
int main() {
    ifstream cin("capsuni.in");
    ofstream cout("capsuni.out");
    cin >> N >> M >> K;
    long long tr = N, tc = M;
    for(int i = 1; i <= K; ++i) {
        cin >> x >> y;
        tr = tr - (A[x] == 0);
        A[x] = 1;
        tc = tc - (B[y] == 0);
        B[y] = 1;
    }
    cout << tr * M + tc * N - tr * tc << '\n';
    return 0;
}