66 分求调。(WA in #99)
查看原帖
66 分求调。(WA in #99)
1283944
Hanrui1206楼主2025/1/18 16:28
#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
char a[1010][10];

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= 6; j ++) {
			cin >> a[i][j];
			if (a[i][j] == 'X') {
				ans ++;
			}
		}
	}
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= 6; j ++) {
			if (a[i][j] == 'X') {
				if (a[i][6 - j + 1] != 'X') {
					a[i][6 - j + 1] = 'X';
					m --;
				}
			}
		}
	}
	if (m < 0 || m % 2 == 1 || n * 6 - ans < m) {
		cout << "Impossible";
		return 0;
	} 
	bool f = false;
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= 6; j ++) {
			if (m == 0) {
				f = true;
				break;
			}
			if (a[i][j] == '.') {
				a[i][j] = 'X';
				a[i][6 - j + 1] = 'X';
				m -= 2;
			}
		}
		if (f == true) {
			break;
		}
	}
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= 6; j ++) {
			cout << a[i][j];
		}
		cout << '\n';
	}
	return 0;
}

错误信息:Wrong Answer.wrong answer Added passengers number is not equal to m(错误的答案。错误答案添加的乘客数量不等于m)。

没发现哪有问题……

2025/1/18 16:28
加载中...