結果

問題 No.11 カードマッチ
ユーザー prog470prog470
提出日時 2016-08-27 16:28:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,234 ms / 5,000 ms
コード長 707 bytes
コンパイル時間 553 ms
コンパイル使用メモリ 75,512 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-08 13:39:00
合計ジャッジ時間 7,534 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 611 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 999 ms
4,380 KB
testcase_07 AC 29 ms
4,380 KB
testcase_08 AC 541 ms
4,380 KB
testcase_09 AC 1,234 ms
4,380 KB
testcase_10 AC 481 ms
4,380 KB
testcase_11 AC 515 ms
4,376 KB
testcase_12 AC 567 ms
4,380 KB
testcase_13 AC 432 ms
4,380 KB
testcase_14 AC 529 ms
4,380 KB
testcase_15 AC 6 ms
4,380 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>

using namespace std;

int main() {

	int W, H, N, S[105], K[105];
	cin >> W >> H >> N;
	for (int i = 0; i < N; i++) {
		cin >> S[i] >> K[i];
	}

	long long  ans = 0;
	set<int> s1, s2;
	for (int i = 0; i < W; i++) {
		int cnt = 0;
		bool flag = false;
		for (int j = 0; j<N; j++) {
			if (S[j] == i + 1) {
				cnt++;
				flag = true;
			}
			s2.insert(K[j]);
		}
		if (flag) {
			ans += H - cnt;
			s1.insert(i + 1);
			flag = false;
		}
	}

	ans += (W - s1.size())*s2.size();

	cout << ans << endl;

	return 0;
}
0