CSP斗地主

题目

斗地主
如果看不了请登入,如果还看不了就是你没去qbxt

就是一个大模拟,没别的了

Code

#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define int long long
#define rr register

#define MAXN 10010
#define MAXM 110
#define inf 1e18

using namespace std;

const int mod = 1e9 + 7;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) {f |= ch == '-'; ch = getchar();}
	while (isdigit(ch)) {s = s * 10 + (ch ^ 48); ch = getchar();}
	return f ? -s : s;
}

int T, n1, n2;

int q[MAXM], p[MAXM];

int a[MAXM][MAXM], b[MAXM][MAXM];

inline int chen(int x) {return (x - 3 + 14) % 14;}

inline int check() {
	int x1 = 0, x2 = 0, x3 = 0, x4 = 0, d1 = 0, d2 = 0;
	for (rr int i = 1; i <= 13; i++) {
		if (q[i] == 4)
			d1 = i;
		else if (q[i] == 3) x1 = i;
		else if (q[i] == 1) x2 = i;
	}
	for (rr int i = 1; i <= 13; i++) {
		if (p[i] == 4)
			d2 = i;
		else if (p[i] == 3) x3 = i;
		else if (p[i] == 1)  x4 = i;
	}
	// cout << 1;
	if (n1 == 4) {
		if (!d1 && ((!x1) || (!x2)))
		return 0;
	}
	if (n2 == 4) {
		if (!d2 && ((!x3) || (!x4)))
		return 0;
	}
	if (d1 && d2 && n1 == 4 && n2 == 4) {
		if (chen(d1) > chen(d2)) return 1;
		else if (chen(d1) < chen(d2)) return 2;
		else return 0;
	}
	if (d1 && !d2 && n1 == 4) return 1;
	if (!d1 && d2 && n2 == 4) return 2;
	if (x1 && x3 && n1 == 4 && n2 == 4) {
		if (chen(x1) > chen(x3)) return 1;
		else if (chen(x1) < chen(x3)) return 2;
		else return 0;
	}
	if (x1 && !x3 && n1 == 4) return 0;
	if (!x1 && x3 && n2 == 4) return 0;
	if (x2 && x4 && n1 == 1 && n2 == 1) {
		// cout << chen(x2) << chen(x4);
		if (chen(x2) > chen(x4)) return 1;
		else if (chen(x2) < chen(x4)) return 2;
		else return 0;
	}
	return 0;
}

signed main() {
	T = read();
	while (T--) {
		memset(a, 0, sizeof a);
		memset(q, 0, sizeof q);
		memset(p, 0, sizeof p);
		memset(b, 0, sizeof b);
		n1 = read();
		bool f = 0;
		for (rr int i = 1 ; i <= n1; i++) {
			int x = read();
			int y = read();
			if (a[x][y]) f = 1;
			a[x][y] = 1;
			q[y]++;
		}
		n2 = read();
		for (rr int i = 1 ; i <= n2; i++) {
			int x = read();
			int y = read();
			if (a[x][y] || b[x][y]) f = 1;
			b[x][y] = 1;
			p[y]++;
		}
		if (f) {
			cout << 0 << "\n";
			continue;
		}
		if (n1 > 4 || n2 > 4 || n1 == 2 || n1 == 3 || n2 == 2 || n2 == 3 || (n1 != n2 && n1 != 4 && n2 != 4)) {
			cout << 0 << "\n";
			continue;
		}
		cout << check() << "\n";
	}
}

自造数据

/*
2
4 1 2 2 2 3 2 0 2
1 1 4
4 1 2 2 2 3 2 0 1
1 1 3
*/
/*
1 0
*/
/*
2
4 1 2 2 2 3 2 0 1
4 0 2 1 1 2 1 3 1
4 1 2 2 2 3 2 0 2
4 0 1 1 1 2 3 3 3
*/
/*
1 0
*/
/*
2
4 1 2 2 3 3 4 0 1
4 5 6 7 8 8 9 10 11
4 1 2 2 2 3 2 0 2
4 0 1 1 1 2 3 3 3
*/
posted @ 2020-05-02 10:00  Aliemo  阅读(162)  评论(4编辑  收藏  举报