(ICPC)亚洲区域赛(上海)Mine Sweeper II(思维)
发布日期:2021-06-30 10:33:07 浏览次数:2 分类:技术文章

本文共 818 字,大约阅读时间需要 2 分钟。

设一个空格子周围有 x x x颗雷,那么这个格子的数字是 x x x

此时如果把周围的 x x x颗雷变成空格子,原来的空格子变成雷

那么中间的雷(原来的空格子)会给周围的 x x x个空格子(原来的雷),每个贡献 1 1 1

从这个角度来看,原图和补图的数字是相等的

这启示我们把 B B B变成 A A A或者 A A A的补图即可

转化次数一定有一个小于一半,所以一定有解

#include
using namespace std;const int maxn = 1e3+10;char a[1009][1009],b[1009][1009];int n,m,t;int main(){
cin >> n >> m; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin >> a[i][j]; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin >> b[i][j]; int ans = 0; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) {
if( a[i][j]!=b[i][j] ) ans++; } if( ans<=n*m/2 ) {
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) cout << a[i][j]; cout << endl; } } else {
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
if( a[i][j]=='.' ) cout << 'X'; else cout << "."; } cout << endl; } }}

转载地址:https://issue-is-vegetable.blog.csdn.net/article/details/116669442 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:45届ICPC亚洲区域赛(上海)C.Sum of Log(卡常数位dp)
下一篇:(ICPC)亚洲区域赛上海 M.Gitignore(模拟,map)

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年04月04日 18时22分10秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章