为什么有些测试点WA了
查看原帖
为什么有些测试点WA了
773235
dctc1494楼主2023/11/25 14:17
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <array>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iterator>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

const int N = 1e1 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;

const int bishop_dx[4] = {1, 1, -1, -1};
const int bishop_dy[4] = {1, -1, 1, -1};

bool v[N][N];
char g[N][N];

void init() {
	memset(v, true, sizeof(v));
}

void rook(int x, int y) {
	for (int i(1); i <= 8; ++i) {
		v[x][i] = false;
	}
	for (int i(1); i <= 8; ++i) {
		v[i][y] = false;
	}
}

void bishop(int x, int y) {
	for (int k(0); k <= 4; ++k) {
		int i(x);
		int j(y);
		while (i >= 1 && j >= 1 && i <= 8 && j <= 8) {
			v[i][j] = false;
			i += bishop_dx[k];
			j += bishop_dy[k];
		}
	}
}

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	init();

	for (int i(1); i <= 8; ++i) {
		for (int j(1); j <= 8; ++j) {
			cin >> g[i][j];
			if (g[i][j] == 'R') {
				rook(i, j);
			} else if (g[i][j] == 'B') {
				bishop(i, j);
			}
		}
	}

	for (int i(1); i <= 8; ++i) {
		for (int j(1); j <= 8; ++j) {
			if (v[i][j]) {
				cout << "1";
			} else {
				cout << "0";
			}
		}
		cout << endl;
	}

	return 0;
}

代码WA掉了怎么办?

2023/11/25 14:17
加载中...