Codeforces Round #719 (Div. 3) C. Not Adjacent Matrix
地址 Problem - C - Codeforces
题意
每个格子,该格子和相邻的格子的值不能相同
题解
思维题, 先从1~n输出奇数,再输出偶数
代码
#include <iostream>
#include <string>
#include <algorithm> using namespace std; typedef long long LL; int a[110][110]; int main()
{
LL n, t;
cin >> t;
while(t --)
{
cin >> n;
if(n == 2)
{
puts("-1");
continue;
}
int step = -1;
for(int i = 1; i <= n; i ++)
{
for(int j = 1; j <= n; j ++)
{
step += 2;
if(step > n*n) step = 2;
cout << step << ' ';
}
puts("");
}
}
return 0;
}
Codeforces Round #719 (Div. 3) C. Not Adjacent Matrix的更多相关文章
- 刷题记录:Codeforces Round #719 (Div. 3)
Codeforces Round #719 (Div. 3) 20210703.网址:https://codeforces.com/contest/1520. 没错,我是个做div3的蒟蒻-- A 大 ...
- Codeforces Round #277 (Div. 2) B. OR in Matrix 贪心
B. OR in Matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/486/probl ...
- Codeforces Round #495 (Div. 2) D. Sonya and Matrix
http://codeforces.com/contest/1004/problem/D 题意: 在n×m的方格中,选定一个点(x,y)作为中心点,该点的值为0,其余点的值为点到中心点的曼哈顿距离. ...
- Codeforces Round #524 (Div. 2) E. Sonya and Matrix Beauty(字符串哈希,马拉车)
https://codeforces.com/contest/1080/problem/E 题意 有一个n*m(<=250)的字符矩阵,对于每个子矩阵的每一行可以任意交换字符的顺序,使得每一行每 ...
- Codeforces Round #236 (Div. 2)E. Strictly Positive Matrix(402E)
E. Strictly Positive Matrix You have matrix a of size n × n. Let's number the rows of the matrix f ...
- Codeforces Round #277 (Div. 2) B.OR in Matrix 模拟
B. OR in Matrix Let's define logical OR as an operation on two logical values (i. e. values that b ...
- Codeforces Round #486 (Div. 3) E. Divisibility by 25
Codeforces Round #486 (Div. 3) E. Divisibility by 25 题目连接: http://codeforces.com/group/T0ITBvoeEx/co ...
- Codeforces Round #486 (Div. 3) D. Points and Powers of Two
Codeforces Round #486 (Div. 3) D. Points and Powers of Two 题目连接: http://codeforces.com/group/T0ITBvo ...
- Codeforces Round #297 (Div. 2)D. Arthur and Walls 暴力搜索
Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec Memory Limit: 512 MBSubmit: xxx ...
随机推荐
- python3生成10个成绩列表,求其平均分
import random alist = [random.randint(45,101) for _ in range(10)] #在[45.101)之间生成10个随机数 print(alist) ...
- 【公告】淘宝 npm 域名即将切换 && npmmirror 重构升级
镜像下载.域名解析.时间同步请点击阿里云开源镜像站 前言 本文将包括两部分内容: 淘宝 npm 域名即将停止解析 npmmirror 镜像站大重构升级 原淘宝 npm 域名即将停止解析 正如在< ...
- Zabbix 4.4管理界面中文乱码解决方法
1.zabbix 4.4 安装配置过程可参考官方文档: 文档链接地址:https://www.zabbix.com/download?zabbix=4.4&os_distribution=ce ...
- rest-framework之视图和源码解析
视图和源码解析 通过使用mixin类编写视图: from rest_framework import mixins from rest_framework import generics class ...
- 4月11日 python学习总结 对象与类
1.类的定义 #类的定义 class 类名: 属性='xxx' def __init__(self): self.name='enon' self.age=18 def other_func: pas ...
- SQL存储过程的学习01
虽工作多年,但是sql的存储过程一致都没怎么用过,今天来按照博客https://www.cnblogs.com/applelife/p/11016674.html来学习一下(我使用postgre sq ...
- HashMap 链表和红黑树的转换
HashMap在jdk1.8之后引入了红黑树的概念,表示若桶中链表元素超过8时,会自动转化成红黑树:若桶中元素小于等于6时,树结构还原成链表形式. 原因: 红黑树的平均查找长度是log(n),长度为8 ...
- 去掉一个Vector集合中重复的元素?
Vector newVector = new Vector();For (int i=0;i<vector.size();i++){Object obj = vector.get(i); ...
- 怎样将 GB2312 编码的字符串转换为 ISO-8859-1 编码的 字符串?
String s1 = "你好"; String s2 = new String(s1.getBytes("GB2312"), "ISO-8859-1 ...
- PRODUCER配置加载
1.入口 Kafka通过new一个KafkaProducer将配置项进行加载.将用户定义的properties作为参数,构造成一个ProducerConfig对象. public KafkaProdu ...