結果
| 問題 | No.11 カードマッチ | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2015-01-20 03:02:21 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 694 bytes | 
| コンパイル時間 | 572 ms | 
| コンパイル使用メモリ | 69,880 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-11 19:36:31 | 
| 合計ジャッジ時間 | 1,267 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 | 
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
int main() {
	int w, h, n;
	cin >> w >> h >> n;
	vector<int> s(n);
	vector<int> k(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> k[i];
	}
	set<int> used_w, used_h;
	long long total = 0;
	for (int i = 0; i < n; i++) {
		bool unused_w = used_w.count(s[i]) == 0;
		bool unused_h = used_h.count(k[i]) == 0;
		if (unused_w) {
			total += h - used_h.size() - 1;
		}
		if (unused_h) {
			total += w - used_w.size() - 1;
		}
		if (!unused_w && !unused_h) {
			total--;
		}
		used_w.insert(s[i]);
		used_h.insert(k[i]);
	}
	cout << total << endl;
	return 0;
}
            
            
            
        