求助,第一个RE,第二个AC,其余全WA,调试快两个小时了
查看原帖
求助,第一个RE,第二个AC,其余全WA,调试快两个小时了
439884
Leave旭日冬升楼主2024/7/23 14:37
#include<iostream>
#include<string.h>
using namespace std;
int FS1[110], FS2[110], FR1[110], FR2[110];
int FS3[110][110], FR3[110][110];
int n, m, r, s, x, y, num1, num2;
void inputFS(int a, int b) { //FS出牌
	if (!a && !b) {//出第一张牌
		int tempx, tempy = r;
		for (int i = 0; i < n; i++) {
			if (FS2[i] < tempy) {
				tempy = FS2[i];
				tempx = FS1[i];
			} else if (FS2[i] == tempy) {
				if (FS1[i] < tempx) {
					tempy = FS2[i];
					tempx = FS1[i];
				}
			}
		}
		num1--;
		x = tempx;
		y = tempy;
		FS3[x][y] = 1;
	} else { //后续的牌
		int Y = b;
		for (int i = 0; i < n; i++) {
			if (FS1[i] == a) {
				if (FS2[i] > Y && !FS3[a][FS2[i]]) {
					Y = FS2[i];
				}
			}
		}
		y = Y;
		if (y == b) {
			x = 0, y = 0;
		} else {
			FS3[x][y] = 1;
			num1--;
		}
	}
	if (num1 == 0) {
		cout << "FS wins!" << endl;
	}
}
void inputFR(int a, int b) { //FR出牌
	if (!a && !b) {//出第一张牌
		int tempx, tempy = r;
		for (int i = 0; i < n; i++) {
			if (FR2[i] < tempy) {
				tempy = FR2[i];
				tempx = FR1[i];
			} else if (FR2[i] == tempy) {
				if (FR1[i] < tempx) {
					tempy = FR2[i];
					tempx = FR1[i];
				}
			}
		}
		num2--;
		x = tempx;
		y = tempy;
		FR3[x][y] = 1;
	} else { //后续的牌
		int Y = b;
		for (int i = 0; i < n; i++) {
			if (FR1[i] == a) {
				if (FR2[i] > Y && !FR3[a][FR2[i]]) {
					Y = FR2[i];
				}
			}
		}
		y = Y;
		if (y == b) {
			x = 0, y = 0;
		}else{
			FR3[x][y] = 1;
			num2--;
		}
	}
	if (num2 == 0) {
		cout << "FR wins!" << endl;
	}
}
int main() {
	int T;
	cin >> T;
	for (int j = 1; j <= T; j++) {
		cin >> n >> m >> r >> s;
		for (int i = 0; i < n; i++) {
			cin >> FS1[i];
		}
		for (int i = 0; i < n; i++) {
			cin >> FS2[i];
		}
		for (int i = 0; i < n; i++) {
			cin >> FR1[i];
		}
		for (int i = 0; i < n; i++) {
			cin >> FR2[i];
		}
		x = 0, y = 0; //第一次出牌
		num1 = n, num2 = n; //两人手中牌的数量
		memset(FS3, 0, sizeof(FS3));
		memset(FR3, 0, sizeof(FR3));
		while (1) {
			if (s == 1) {
				inputFS(x, y);
				s = 2;
			} else {
				inputFR(x, y);
				s = 1;
			}
			if (num1 == 0 || num2 == 0) {
				break;
			}
		}
	}
	return 0;
}
2024/7/23 14:37
加载中...