链接:

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. Windows应急响应常见命令

    ---恢复内容开始--- 1.查看所有连接的PID netstat -ano 2.过滤特定端口 netstat -ano | findstr “443” 3.查看占用443端口的进程 tasklist ...

  2. redis快速开始

    1 下载地址:http://redis.io/download 2 安装步骤: 3 # 安装gcc 4 yum install gcc 5 6 # 把下载好的redis‐5.0.3.tar.gz放在/ ...

  3. Docker的安装和学习

    dockers学习 2019年2月23日开始     docker系统要求             centos 7 核心为3.1以上         centos6.5以上 核心为 2.6以上    ...

  4. python+pycharm+django admin css样式出问题

    最近打算学习一下Python,基础知识有了大概的了解,想上手搞搞东西. 我用的python 3.5+pycharm+django 1.11.2 在使用Django,打开127.0.0.1:8000/a ...

  5. Python基础总结之第六天开始【先简单认识一次函数】(新手可相互督促)

    午休后,看看电视,在回顾下新的知识----函数.相信很多小伙伴在学习python后 ,学到函数就会有一部分人放弃了,从努力到放弃(内容过于真实) 好希望我也能有很多粉丝,hhh.... 函数: 什么是 ...

  6. 20190804-Python基础 第二章 列表和元组

    容器,Python支持一种数据结构的基本概念(容器,基本上就是可包含其他对象的对象.) 两种主要的容器是:序列(如列表和元组)和映射(如字典) Ps: 列表与元组区别,列表可修改,元组不能. 对序列的 ...

  7. kafka常见问题

    (1)  如果想消费已经被消费过的数据 consumer是底层采用的是一个阻塞队列,只要一有producer生产数据,那consumer就会将数据消费.当然这里会产生一个很严重的问题,如果你重启一消费 ...

  8. JS — 事件的相关概念和DOM

    JS是以事件驱动为核心的一门语言. 事件的三要素:事件源.事件.事件驱动程序. 例如: <body> <div id="box1"></div> ...

  9. ThreeJS 3d模型简介

    本文主要是对Threejs中加载模型的支持种类进行简单的知识科普. 3ds (.3ds) 3ds是3ds max通用储存文件格式.使用的范围更宽,可被更多的软件识别使用. amf (.amf) AMF ...

  10. 使用pycharm 编写代码 并在远程主机上运行

    一 要求 远程主机有python解释器 二 在菜单栏,File -> Settings… -> Project ×× -> Project Interpreter,点击右侧 Add按 ...