链接:

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(构造)的更多相关文章

  1. Educational Codeforces Round 73 (Rated for Div. 2)

    传送门 A. 2048 Game 乱搞即可. Code #include <bits/stdc++.h> #define MP make_pair #define fi first #de ...

  2. Educational Codeforces Round 73 (Rated for Div. 2) D. Make The Fence Great Again(DP)

    链接: https://codeforces.com/contest/1221/problem/D 题意: You have a fence consisting of n vertical boar ...

  3. Educational Codeforces Round 73 (Rated for Div. 2) C. Perfect Team

    链接: https://codeforces.com/contest/1221/problem/C 题意: You may have already known that a standard ICP ...

  4. Educational Codeforces Round 73 (Rated for Div. 2) A. 2048 Game

    链接: https://codeforces.com/contest/1221/problem/A 题意: You are playing a variation of game 2048. Init ...

  5. Educational Codeforces Round 73 (Rated for Div. 2)F(线段树,扫描线)

    这道题里线段树用来区间更新(每次给更大的区间加上当前区间的权重),用log的复杂度加快了更新速度,也用了区间查询(查询当前区间向右直至最右中以当前区间端点向右一段区间的和中最大的那一段的和),也用lo ...

  6. Educational Codeforces Round 73 (Rated for Div. 2)E(思维,博弈)

    //这道题博弈的核心就是不能让后手有一段只能放b而长度不够放a的段,并且先手要放最后一次#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h> ...

  7. Educational Codeforces Round 73 (Rated for Div. 2)D(DP,思维)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;long long a[300007],b[3 ...

  8. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  9. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

随机推荐

  1. poj1915(双向bfs)

    题目链接:https://vjudge.net/problem/POJ-1915 题意:求棋盘上起点到终点最少的步数. 思路:双向广搜模板题,但玄学的是我的代码G++会wa,C++过了,没找到原因QA ...

  2. Upgrading CentOS 6 to CentOS 7

    Upgrading CentOS 6 to CentOS 7 November 15th, 2018 — whplus PRE TASKS There are some tasks you can d ...

  3. thinkphp中return $this->fetch的问题

    当reture放在foreach循环外面,也就是现在的位置的时候,会报错.如下图.但当return放在foreach语句里面的时候就不会报错,但因为return会结束语句,这也就导致了foreach只 ...

  4. 安装sqlserver导致80端口被占用解决方法

    安装sqlserver导致80端口被占用解决方法 系统占用的端口一般都是微软官方的产品占用的.所以这个时候主要考虑到几个服务: SQL Server导致.其中很有可能是SQL Server Repor ...

  5. LeetCode. 位1的个数

    题目要求: 编写一个函数,输入是一个无符号整数,返回其二进制表达式中数字位数为 '1' 的个数(也被称为汉明重量). 示例: 输入:00000000000000000000000000001011 输 ...

  6. macos catalina安装python3

    之前跟着教程用brow安装了python3,后来发现电脑上有三个版本的python,头大. 于是用brew uninstall --force python3卸掉了python3 看到现在有两个版本 ...

  7. hdu 6047

    题解:先对b排序,用一个数组预处理a,记录当前位置之后到n的最大值,然后在用一个变量维护新增变量的最大值,用的时候和前面的数组的最大值做一个比较就ok. AC代码: #include <cstd ...

  8. hdu 1572 全排列的搜索

    好久没写搜索的题目了 复习一下/./ 这道题目是暴力的全排列#include<cstdio> #include<iostream> #include<cstring> ...

  9. nginx触屏版跟PC的代理设置

    server { listen ; set $mobile_rewrite do_not_perform; if ( $http_user_agent ~* "(android|bb\d+| ...

  10. JS实现旋转的魔方

    js <script> window.onload = function () { let cube = document.querySelector('.cube') let timer ...