标签:class example possible hit 上下 its codeforce bit https
https://codeforces.com/contest/1221/problem/B
You are given a chess board with n rows and n columns. Initially all cells of the board are empty, and you have to put a white or a black knight into each cell of the board.
A knight is a chess piece that can attack a piece in cell (x2, y2) from the cell (x1, y1) if one of the following conditions is met:
|x1?x2|=2 and |y1?y2|=1, or
|x1?x2|=1 and |y1?y2|=2.
Here are some examples of which cells knight can attack. In each of the following pictures, if the knight is currently in the blue cell, it can attack all red cells (and only them).
A duel of knights is a pair of knights of different colors such that these knights attack each other. You have to put a knight (a white one or a black one) into each cell in such a way that the number of duels is maximum possible.
画个3x3的图就行了, 上下左右不同即可.
#include <bits/stdc++.h>
using namespace std;
int main()
{
char col[5] = "WB";
int n;
cin >> n;
for (int i = 0;i < n;i++)
{
for (int j = 0;j < n;j++)
{
cout << col[(i+j)%2];
}
cout << endl;
}
return 0;
}
Educational Codeforces Round 73 (Rated for Div. 2) B. Knights(构造)
标签:class example possible hit 上下 its codeforce bit https
原文地址:https://www.cnblogs.com/YDDDD/p/11625451.html