码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • D. Anti-Sudoku


    D. Anti-Sudoku

    time limit per test

    2 seconds

    memory limit per test

    256 megabytes

    input

    standard input

    output

    standard output

    You are given a correct solution of the sudoku puzzle. If you don't know what is the sudoku, you can read about it here.

    The picture showing the correct sudoku solution:

    正在上传…重新上传取消

    Blocks are bordered with bold black color.

    Your task is to change at most 99 elements of this field (i.e. choose some 1≤i,j≤91≤i,j≤9 and change the number at the position (i,j)(i,j) to any other number in range [1;9][1;9]) to make it anti-sudoku. The anti-sudoku is the 9×99×9 field, in which:

    • Any number in this field is in range [1;9][1;9];
    • each row contains at least two equal elements;
    • each column contains at least two equal elements;
    • each 3×33×3 block (you can read what is the block in the link above) contains at least two equal elements.

    It is guaranteed that the answer exists.

    You have to answer tt independent test cases.

    Input

    The first line of the input contains one integer tt (1≤t≤1041≤t≤104) — the number of test cases. Then tt test cases follow.

    Each test case consists of 99 lines, each line consists of 99 characters from 11 to 99 without any whitespaces — the correct solution of the sudoku puzzle.

    Output

    For each test case, print the answer — the initial field with at most 99 changed elements so that the obtained field is anti-sudoku. If there are several solutions, you can print any. It is guaranteed that the answer exists.

    Example

    input

    Copy

    1
    154873296
    386592714
    729641835
    863725149
    975314628
    412968357
    631457982
    598236471
    247189563
    

    output

    Copy

    154873396
    336592714
    729645835
    863725145
    979314628
    412958357
    631457992
    998236471
    247789563
    

    =========================================================================

    脑筋急转弯,不过要先知道数独的定义,也就是每个粗9格里面是1-9无重复,每行1-9无重复,每列1-9无重复

    那么也就是说每行一个1,一个2,每列一个1,一个2,每个粗9格一个1,一个2,然后整个八十一格9个1,9个2,我们只需要把1改成2,那么每行两个2,每列两个2,每个粗9格两个2

    脑筋急转弯

    1. # include
    2. using namespace std;
    3. char s[100][100];
    4. int main ()
    5. {
    6. int t;
    7. cin>>t;
    8. while(t--)
    9. {
    10. for(int i=1;i<=9;i++)
    11. {
    12. for(int j=1;j<=9;j++)
    13. {
    14. cin>>s[i][j];
    15. }
    16. }
    17. for(int i=1;i<=9;i++)
    18. {
    19. for(int j=1;j<=9;j++)
    20. {
    21. if(s[i][j]=='1')
    22. cout<<'2';
    23. else
    24. cout<<s[i][j];
    25. }
    26. cout<
    27. }
    28. }
    29. return 0;
    30. }

  • 相关阅读:
    元素可以定位到,但是不进行点击--问题解决js点击处理
    TeamTalk中msg_server初始化工作,如何维护与其他服务器的心跳连接
    7天酒店亮相“2022锦江行”17年国民历史酒店再启新程
    《MySQL数据库进阶实战》读后感(SQL 小虚竹)
    Pytorch 自己搭建的一个神经网络
    基于matomo实现业务数据埋点采集上报
    Node学习(二)01-node核心模块之path模块——extname()-获取文件后缀 & join()-智能拼接路径
    从转载阿里开源项目 Egg.js 技术文档引发的“版权纠纷”,看宽松的 MIT 许可该如何用?
    Ranger (五) --------- 使用 Ranger 对 Hive 进行权限管理
    《视觉SLAM十四讲》公式推导(二)
  • 原文地址:https://blog.csdn.net/jisuanji2606414/article/details/126283420
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号