Codeforces Round 804 (Div. 2)

1|0基本情况

A题+2,幸好后面突然悟了。

B题体现了读题以及一词多义的重要性。

C题不会。看了一下1700分的题目,暂时先放了。

2|0A. The Third Three Number Problem

Problem - A - Codeforces

推出了规律,n 为偶数的时候,无脑 a=n1,b=n1,c=1 就行。然而奇数时却死活推不出来。

后面突然想到,有没有一种可能:奇数就是无解?

然后还真是。。。

3|0B. Almost Ternary Matrix

Problem - B - Codeforces

3|1分析错误

先挂一下部分题面:

You are given two even integers n and m. Your task is to find any binary matrix a with n rows and m columns where every cell (i,j) has exactly two neighbours with a different value than ai,j.

想法是很接近正解的,都是想从 2×2 的小方阵入手搞一个构造,但没有继续想下去,要深究为什么:

  • 迷信样例,结果被第三个样例骗了,以为答案不能由小方阵无脑构成,但实际上答案不唯一,有用小方阵无脑构成的答案:

    样例: 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 另一个答案: 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1
  • even我认为是“甚至”,还在想是啥意思。结果赛后看了一下,是偶数

这两个因素导致了我没有继续想下去,然后就各种玄学尝试无果了。

3|2改正 AC

知道 n,m 为偶数之后,自己就可以做了。

因为就两个子矩形:

1 0 0 1 0 1 1 0

直接按行按列判断条件允许就填入就行。

#include<iostream> #include<algorithm> #include<cstring> int matrix[3][3]; int ans[55][55]; int vis[55][55]; void close_sync() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); } void setLine(int x, int y, bool opt) { if (opt) matrix[1][1] = 1, matrix[1][2] = 0, matrix[2][1] = 0, matrix[2][2] = 1; else matrix[1][1] = 0, matrix[1][2] = 1, matrix[2][1] = 1, matrix[2][2] = 0; for (int i = x * 2 - 1, cntA = 1; i <= x * 2; i++, cntA++) { for (int j = y * 2 - 1, cntB = 1; j <= y * 2; j++, cntB++) { ans[i][j] = matrix[cntA][cntB]; } } } void solve() { int n, m; memset(ans, 0, sizeof(ans)); std::cin >> n >> m; int tn = n >> 1, tm = m >> 1; for (int i = 1; i <= tn; i++) { vis[i][1] = !vis[i - 1][1]; setLine(i, 1, vis[i][1]); for (int j = 2; j <= tm; j++) { vis[i][j] = !vis[i][j - 1]; setLine(i, j, vis[i][j]); } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { std::cout << ans[i][j] << " "; } std::cout << std::endl; } } int main() { close_sync(); int _; std::cin >> _; while(_--) solve(); return 0; }

__EOF__

本文作者Kdlyh
本文链接https://www.cnblogs.com/kdlyh/p/17895046.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   加固文明幻景  阅读(55)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下
点击右上角即可分享
微信分享提示