Educational Codeforces Round 73 (Rated for Div. 2) B. Knights(构造)
链接:
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(构造)的更多相关文章
- Educational Codeforces Round 73 (Rated for Div. 2)
传送门 A. 2048 Game 乱搞即可. Code #include <bits/stdc++.h> #define MP make_pair #define fi first #de ...
- 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 ...
- 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 ...
- 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 ...
- Educational Codeforces Round 73 (Rated for Div. 2)F(线段树,扫描线)
这道题里线段树用来区间更新(每次给更大的区间加上当前区间的权重),用log的复杂度加快了更新速度,也用了区间查询(查询当前区间向右直至最右中以当前区间端点向右一段区间的和中最大的那一段的和),也用lo ...
- Educational Codeforces Round 73 (Rated for Div. 2)E(思维,博弈)
//这道题博弈的核心就是不能让后手有一段只能放b而长度不够放a的段,并且先手要放最后一次#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h> ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- msyql 主从切换
从库是192.168.1.70 ,主库是192.168.1.64,主从切换一次 即:主库是192.168.1.70,从库是192.168.1.64 1.从库上执行,修改为主 修改从库为非只读库修改配置 ...
- java版MD5签名工具类
package com.net.util; import java.security.MessageDigest; /** * MD5签名工具类 * @author zhangdi * */ publ ...
- MySql设计表中的create_time和update_time字段
一般create_time和update_time字段的类型为datetime类型,长度为0
- (十四)mybatis 和 spring 整合
目录 整合思想 整合步骤 整合之后原始 dao 开发 整合之后 Mapper 代理开发 总结 整合思想 让 spring 管理 sqlSessionFactory ,使用 单例模式 创建该对象 : 根 ...
- Technocup 2020 - Elimination Round 1补题
慢慢来. 题目册 题目 A B C D tag math strings greedy dp 状态 √ √ √ √ //∅,√,× 想法 A. CME res tp A 题意:有\(n\)根火柴,额外 ...
- Windows安全日志
在运行中输入:eventvwr.msc,即可打开事件日志. 登录类型 描述 2 互动(键盘和屏幕的登录系统) 3 网络(即连接到共享文件夹从其他地方在这台电脑上网络) 4 批处理(即计划任务) 5 服 ...
- docker服务端与客户端通信方式
docker的服务端与客户端间可以通过unix.tcp方式进行通信.但默认情况下,服务端只监听本地unix接口/var/run/docker.sock,所以客户端只能在服务端所在的机器上使用该unix ...
- 1.CentOS 7 vs CentOS 6的不同
CentOS 7 vs CentOS 6的不同(1)桌面系统[CentOS6] GNOME 2.x[CentOS7] GNOME 3.x(GNOME Shell) (2)文件系统[CentOS6] ...
- 【AC自动机】病毒
[题目链接] https://loj.ac/problem/10062 [题意] 寻找一个没有模式串为子串的无限01串.是否存在. [题解] 其实就是用dfs找一个环. 1.环需要从根结点出发找到这个 ...
- Oracle练习(一)
Oracle 1.检索部门编号.部门名称.部门所在地及其每个部门的员工总数. select d.deptno,d.dname,d.loc,count(*) from emp e,dept d wher ...