結果

問題 No.11 カードマッチ
ユーザー dgd1724
提出日時 2016-11-01 06:45:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 246 ms / 5,000 ms
コード長 742 bytes
コンパイル時間 1,134 ms
コンパイル使用メモリ 160,824 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-25 00:38:43
合計ジャッジ時間 3,186 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

//const static double	de_PI	= 3.14159265358979323846;
//const static int	de_MOD	= 1000000007;
//const static int	de_MAX	= 999999999;
//const static int	de_MIN = -999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());	

	int W = 0, H = 0, N = 0, S = 0, K = 0, ans = 0;
	std::cin >> W >> H >> N;

	std::vector<bool> mark(W, true), number(H, true);

	for (int i = 0; i < N; i++) {
		std::cin >> S >> K;
		if (mark[S - 1]) {
			ans += std::count(number.begin(), number.end(), true) - 1;
			mark[S - 1] = false;
		}
		else {
			ans--;
		}
		if (number[K - 1]) {
			ans += std::count(mark.begin(), mark.end(), true);
			number[K - 1] = false;
		}
	}

	std::cout << ans << std::endl;

}

0