当前位置:网站首页>Elimination games
Elimination games
2022-07-06 02:39:00 【< WRM>】
#include<bits/stdc++.h>
using namespace std;
const int N = 100;
int a[N][N];
int b[N][N];// Express (i,j) Can the grid of position be deleted , Can delete marked as 1, Cannot delete marked 0
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
scanf("%d", &a[i][j]);
b[i][j] = 0;// initialization b
}
}
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
int u=i,d=i,l=j,r=j;
int x=a[i][j];
// from (i,j) Set out , Start in four directions up, down, left and right ,
// When and a[i][j] Only when the values are the same can we move forward in the current direction ,
// When the number of columns or rows is greater than or equal to 3 when , Mark a[i][j] Can be eliminated
while(u>=1&&a[u][j]==x) u--;//
while(d<=n&&a[d][j]==x) d++;
while(r<=m&&a[i][r]==x) r++;
while(l>=1&&a[i][l]==x) l--;
if(d-u-1>=3||r-l-1>=3)
{
b[i][j]=1;
}
}
}
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
if(b[i][j]) printf("%d ",0);
else printf("%d ",a[i][j]);
}
printf("\n");
}
}
边栏推荐
- 零基础自学STM32-复习篇2——使用结构体封装GPIO寄存器
- 微软语音合成助手 v1.3 文本转语音工具,真实语音AI生成器
- 2345 file shredding, powerful file deletion tool, unbound pure extract version
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12
- Sword finger offer 30 Stack containing min function
- QT release exe software and modify exe application icon
- Pure QT version of Chinese chess: realize two-man, man-machine and network games
- 好用的 JS 脚本
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 6
- Initial understanding of pointer variables
猜你喜欢
Redis delete policy
RobotFramework入门(三)WebUI自动化之百度搜索
纯Qt版中国象棋:实现双人对战、人机对战及网络对战
UE4 - how to make a simple TPS role (I) - create a basic role
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9
微软语音合成助手 v1.3 文本转语音工具,真实语音AI生成器
Paper notes: graph neural network gat
Introduction to robotframework (II) app startup of appui automation
A doctor's 22 years in Huawei
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15
随机推荐
550 permission denied occurs when FTP uploads files, which is not a user permission problem
Template_ Find the reverse pair of permutations_ Sort based on merge
深度解析链动2+1模式,颠覆传统卖货思维?
球面透镜与柱面透镜
HDU_p1237_简单计算器_stack
[postgraduate entrance examination English] prepare for 2023, learn list5 words
Spherical lens and cylindrical lens
Briefly describe the implementation principle of redis cluster
Qt发布exe软件及修改exe应用程序图标
HttpRunnerManager安装(三)-Linux下配置myql数据库&初始化数据
解决:AttributeError: ‘str‘ object has no attribute ‘decode‘
主数据管理理论与实践
一位博士在华为的22年
更换gcc版本后,编译出现make[1]: cc: Command not found
全国大学生信息安全赛创新实践赛初赛---misc(永恒的夜)
Bigder:34/100 面试感觉挺好的,没有收到录取
Accident index statistics
从顶会论文看2022年推荐系统序列建模的趋势
[matlab] access of variables and files
[Wu Enda machine learning] week5 programming assignment EX4 - neural network learning