本题WA了,20分原因
查看原帖
本题WA了,20分原因
1046238
vuiv楼主2024/8/13 20:06

code

//B3767
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int f[N][N], p[N][N], c[N];
bool vis[N][N];
int t, n, m, r, s;
int nc (int l, int r, int sp) {
	int iq = -1;
	for (int i = 1; i <= n; i++)
		if (!vis[sp][i]) {
			if (f[sp][i] != l)
				continue;
			if (p[sp][i] <= r)
				continue;
			if (iq == -1)
				iq = i;
			else
				if (p[sp][i] < p[sp][iq])
					iq = i;
		}
	return iq;
}
int rp (int st) {
	int id = 1;
	while (vis[st][id])
		id++;
	for (int i = id + 1; i <= n; i++)
		if (!vis[st][i])
			if (p[st][i] < p[st][id] || (f[st][i] < f[st][id] && p[st][i] == p[st][id]))
				id = i;
	int l = f[st][id], r = p[st][id];
	c[st]--;
	vis[st][id] = 1;
	if (!c[st])
		return st;
	st = 1 - st;
	while ((id = nc (l, r, st)) != -1) {
		r = p[st][id];
		c[st]--;
		vis[st][id] = 1;
		if (!c[st])
			return st;
		st = 1- st;
	}
	return 1 - st;
}
int main () {
//	freopen ("in", "r", stdin);
//	freopen (".out", "w", stdout);
	cin >> t;
	while (t--) {
		cin >> n >> m >> r >> s;
		for (int i = 1; i <= n; i++)
			cin >> f[0][i];
		for (int i = 1; i <= n; i++)
			cin >> p[0][i];
		for (int i = 1; i <= n; i++)
			cin >> f[1][i];
		for (int i = 1; i <= n; i++)
			cin >> p[1][i];
		s--;
		while (c[0] && c[1])
  			s = rp (s);
		if (s)
			cout << "FR wins!\n";
		else
			cout << "FS wins!\n";
	}
	return 0;
}
2024/8/13 20:06
加载中...