比赛 2024暑假C班集训C 评测结果 AAATTTTTTTTTTTTTTTTA
题目名称 洛希的极限 最终得分 20
用户昵称 LikableP 运行时间 79.990 s
代码语言 C++ 内存使用 3.17 MiB
提交时间 2024-07-12 09:20:17
显示代码纯文本
#include <iostream>
#include <fstream>
using namespace std;
typedef long long ll;

const int MOD = 1e9 + 7;

struct RECTANGLE{
	ll x1, y1, x2, y2;
	void input(){
		cin >> x1 >> y1 >> x2 >> y2;
	}
}a[500010];

ll t;
ll cnt, maxx = -1;
ll n, m, q;

bool check(ll x1, ll y1, ll x2, ll y2){
	for(ll i = 1; i <= q; i++){
		if(a[i].x1 <= x1 && a[i].y1 <= y1 && a[i].x2 >= x2 && a[i].y2 >= y2){
			return true;
		}
	}
	return false;
}

void dfs(ll x, ll y, ll step){
	if(step == maxx){
		(cnt += 1) %= MOD;
	}
	if(step > maxx){
		maxx = step;
		cnt = 1;
	}
	for(ll i = x + 1; i <= n; i++){
		for(ll j = y + 1; j <= m; j++){
			if(check(x, y, i, j)){
				dfs(i, j, step + 1);
			}
		}
	}
}

int main(){
	freopen("roche.in", "r", stdin);
	freopen("roche.out", "w", stdout);
	cin >> t;
	while(t--){
		maxx = -1, cnt = 0;
		cin >> n >> m >> q;
		for(ll i = 1; i <= q; i++){
			a[i].input();
		}
		for(ll i = 1; i <= n; i++){
			for(ll j = 1; j <= m; j++){
				dfs(i, j, 1);
			}
		}
		cout << maxx << ' ' << cnt << endl;
	}
	return 0;
}