zoukankan      html  css  js  c++  java
  • 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 << "
    ";
    			continue;
    		}
    		if (n1 > 4 || n2 > 4 || n1 == 2 || n1 == 3 || n2 == 2 || n2 == 3 || (n1 != n2 && n1 != 4 && n2 != 4)) {
    			cout << 0 << "
    ";
    			continue;
    		}
    		cout << check() << "
    ";
    	}
    }
    

    自造数据

    /*
    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
    */
    
  • 相关阅读:
    robot:生成随机的8为纯数字
    RobotFramework:发现一个大坑,当post接口入参为json时,千万不能用sojson转化后的json串(ride解析会有异常,非sojson工具问题),直接用浏览器粘过来的就行
    PHP 检测变量是否为空
    添加自己的discuz 的积分策略
    discuz核心类库class_core的函数注释
    discuz核心函数库function_core的函数注释
    Discuz 任务、道具、任务和验证类插件制作
    apache启动不了, 查找错误
    建设银行网上银行MD5withRSA php版
    php curl常见错误:SSL错误、bool(false)
  • 原文地址:https://www.cnblogs.com/lieberdq/p/12817085.html
Copyright © 2011-2022 走看看