基础赛T3 10pts求助
  • 板块学术版
  • 楼主Indrecht
  • 当前回复13
  • 已保存回复13
  • 发布时间2023/8/26 21:54
  • 上次更新2023/11/3 01:00:29
查看原帖
基础赛T3 10pts求助
544844
Indrecht楼主2023/8/26 21:54

rt.

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iomanip>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
template <typename T>
void read(T &x) {
	x = 0;
	int f = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + (ch - '0');
		ch = getchar();
	}
	x *= f;
}
template <typename T>
void print(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x < 10) putchar(x + '0');
	else {
		print(x / 10);
		putchar(x % 10 + '0');
	}
}
ll n, m, q, k, r[200010], c[200010];
ll ans;
int main() {
//	freopen("paint2.in", "r", stdin);
//	freopen(".out", "w", stdout);
	read(n);read(m);read(q);read(k);
	while (q--) {
		ll op, x;
		read(op);read(x);
		if (op == 1) ++r[x];
		else ++c[x];
	}
	sort(c + 1, c + m + 1);
	ll y = 0;
	for (ll i = 1; i <= m; ++i) if (!c[i]) y = i;
	for (ll i = 1; i <= n; ++i) {
		ll x = lower_bound(c + 1, c + m + 1, k - r[i]) - c - 1ll;
		ans += x;
		if (!r[i]) {
			ans -= y;
		}
	}
	print(ans);
	return 0;
}
2023/8/26 21:54
加载中...