結果

問題 No.11 カードマッチ
ユーザー maimaicorgimaimaicorgi
提出日時 2022-09-15 18:30:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 162 ms / 5,000 ms
コード長 1,845 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 151,036 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-09 19:17:11
合計ジャッジ時間 3,054 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 46 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 158 ms
5,376 KB
testcase_07 AC 54 ms
5,376 KB
testcase_08 AC 84 ms
5,376 KB
testcase_09 AC 162 ms
5,376 KB
testcase_10 AC 67 ms
5,376 KB
testcase_11 AC 75 ms
5,376 KB
testcase_12 AC 81 ms
5,376 KB
testcase_13 AC 74 ms
5,376 KB
testcase_14 AC 57 ms
5,376 KB
testcase_15 AC 5 ms
5,376 KB
testcase_16 AC 10 ms
5,376 KB
testcase_17 AC 10 ms
5,376 KB
testcase_18 AC 9 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <ios>
#include <iomanip>
#include <queue>
#include <numeric>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <climits>
#include <stack>
#include <regex>
#include <functional>
#include <random>
#ifdef _WIN64
#  include <atcoder/all>
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountl __popcnt64
#endif

using namespace std;

#define ll long long
#define rep(i, init, n) for(ll i = init; i < (ll)n; i++)
#define rrep(i, init, n) for(ll i = init; i >= (ll)n; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x.size())
#define Out(x) cout << x << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define Ans cout << ans << endl
#define PI 3.14159265358979
#define MOD 1000000007

const int inf32 = INT_MAX / 2;
const ll inf64 = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

// -------------------------------------------------------------------------------------------------

int main()
{
	ll w, h, n; cin >> w >> h >> n;
	vector<ll> s(n), k(n);
	map<pair<ll, ll>, bool> hand;
	rep(i, 0, n)
	{
		cin >> s[i] >> k[i];
		hand[{s[i], k[i]}] = true;
	}

	ll ans = 0;

	rep(i, 1, w + 1)
	{
		ll cnt = 0;
		rep(j, 0, n) if (s[j] == i) cnt++;
		if (cnt) ans += h - cnt;
	}

	rep(i, 1, h + 1)
	{
		ll cnt = 0;
		rep(j, 0, n) if (k[j] == i) cnt++;
		if (cnt) ans += w - cnt;
	}

	set<pair<ll, ll>> cnt;
	rep(i, 0, n)rep(j, 0, n) if (!hand.count({ s[i],k[j] })) cnt.insert({ s[i],k[j] });
	ans -= cnt.size();

	Ans;

	return 0;
}
0