地址 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的更多相关文章

  1. 刷题记录:Codeforces Round #719 (Div. 3)

    Codeforces Round #719 (Div. 3) 20210703.网址:https://codeforces.com/contest/1520. 没错,我是个做div3的蒟蒻-- A 大 ...

  2. 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 ...

  3. Codeforces Round #495 (Div. 2) D. Sonya and Matrix

    http://codeforces.com/contest/1004/problem/D 题意: 在n×m的方格中,选定一个点(x,y)作为中心点,该点的值为0,其余点的值为点到中心点的曼哈顿距离. ...

  4. Codeforces Round #524 (Div. 2) E. Sonya and Matrix Beauty(字符串哈希,马拉车)

    https://codeforces.com/contest/1080/problem/E 题意 有一个n*m(<=250)的字符矩阵,对于每个子矩阵的每一行可以任意交换字符的顺序,使得每一行每 ...

  5. 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 ...

  6. 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 ...

  7. Codeforces Round #486 (Div. 3) E. Divisibility by 25

    Codeforces Round #486 (Div. 3) E. Divisibility by 25 题目连接: http://codeforces.com/group/T0ITBvoeEx/co ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. ansible 五 playbooks剧本使用

    一.Playbook 简介 Playbooks与Ad-Hoc相比,是一种完全不同的运用Ansible的方式,而且是非常之强大的:也是系统ansible命令的集合,其利用yaml语言编写,运行过程,an ...

  2. 6月28日 Django form组件 和 modelform组件

    Form介绍 我们之前在HTML页面中利用form表单向后端提交数据时,都会写一些获取用户输入的标签并且用form标签把它们包起来. 与此同时我们在好多场景下都需要对用户的输入做校验,比如校验用户是否 ...

  3. [SPDK/NVMe存储技术分析]014 - (NVMe over PCIe)Host端的命令处理流程

    NVMe over PCIe最新的NVMe协议是1.3. 在7.2.1讲了Command Processing流程.有图有真相. This section describes command subm ...

  4. bitsadmin windwos自带下载命令

    bitsadmin的四种下载文件的方法 一. bitsadmin /rawreturn /transfer getfile http://qianxiao996.cn/1.txt c:\1.txt 二 ...

  5. [应用软件] VMware Workstation 12.0.0 Pro 正式版下载【附注册机+注册码】

    软件信息 软件名称: VMware Workstation 软件版本: 12 软件大小: 300 MB 软件语言: 简体中文 更新时间: - 软件授权: 免费 软件类别: 安装版 运行环境: WinX ...

  6. C++ 并发编程2 --向线程函数传递参数

    1向线程函数传递参数比较简单,一般的形式如下 void f(int i,std::string const& s);std::thread t(f,3, "hello"); ...

  7. java三种适配器模式详解与代码实现

    zhaoyu   取消关注   2 人赞同了该文章 1. 适配器模式定义: 适配器模式是一种结构型设计模式,通过一个适配器类把具有不同方法功能的两个类A和B组合起来,使得这个适配器类同时具有两个类的不 ...

  8. Oracle问题解决记录

    一.前言 oracle这么一个庞大的东西,出点问题真是太常见了.开个博客,用于记录遇到的问题吧. 持续更新. 二.问题列表 归档日志满,引起的问题. 一台服务器,用了很久了,某天,出现了磁盘空间占满的 ...

  9. 树莓派基本配置与Docker的安装

    一.树莓派的安装 下载镜像 在 树莓派官网 https://www.raspberrypi.org/downloads/raspbian/ Win32 DiskImager,是一个把系统镜像写入SD卡 ...

  10. 面试问题之操作系统:Linux下进程的内存结构

    转载于:http://www.hqj.com/news/emb184.htm Linux操作系统采用虚拟内存管理技术,使得每个进程都有各自互不干涉的进程地址空间.该地址空间是大小为4GB的线性虚拟空间 ...