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 ...
随机推荐
- Java核心1(第三章)
3.6字符串 子串substring(a,b)方法 第二个参数是不想复制的第一个位置 可以从一个较大的字符串中提取一个子串 3.6.2拼接 Java允许使用+号链接两个字符串 3.6.3不可 ...
- uva 1400 "Ray, Pass me the dishes!" (区间合并 最大子段和+输出左右边界)
题目链接:https://vjudge.net/problem/UVA-1400 题意:给一串序列,求最大子段,如果有多个,输出字典序最小的那个的左右端点 思路: 之前写过类似的,这个麻烦点需要输出左 ...
- Spark的lazy特性有什么意义呢?
[学习笔记] Spark通过lazy特性有什么意义呢? Spark通过lazy特性,可以进行底层的spark应用执行的优化.在生活中,就像三思而后行.谋定而后动. 文章转载自原文:https://bl ...
- Ubuntu 提示sudo: java: command not found解决办法
ubuntu下运行sudo Java 时提示“sudo: java: command not found”.在网上找了,其中很多方法都提示要修改/etc/profile的配置,或是修改/etc/env ...
- SpringBoot热启动让开发更便捷
在开发过程中,当写完一个功能我们需要运行应用程序测试,可能这个小功能中存在多个小bug,我们需要改正后重启服务器,这无形之中拖慢了开发的速度增加了开发时间,SpringBoot提供了spring-bo ...
- Rikka with Competition hdu 6095
签到题目,排序然后按序清理掉一定会输的结果就可以. ac代码: #include <iostream> #include <cstdio> #include <cstri ...
- Ocelot + Consul的demo
参考大佬的博客写的:https://www.cnblogs.com/alan-lin/p/9126155.html:也可以参考这篇博客:https://www.cnblogs.com/axzxs200 ...
- LeetCode:178.分数排名
题目链接:https://leetcode-cn.com/problems/rank-scores/ 题目 编写一个 SQL 查询来实现分数排名.如果两个分数相同,则两个分数排名(Rank)相同.请注 ...
- C语言——指针总结
在创建指针时,我们首先要做的是先初始化它,没有初始化的指针是很危险的,因为指针可以指向一个地址后直接改变它的值,所以为了避免我们的指针在创建后指向一个危险区域(即可能指向系统文件等),我们会先给它一个 ...
- HTML的标签简单概括
段落标签 <p></p> 属性 说明 值 align 对其方式 left(默认).right.center 水平线 <hr /> 属性 说明 值 width ...