当前位置:网站首页>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");
}
}
边栏推荐
- 事故指标统计
- There are so many giants, why should we independently develop POS store cashier system?
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 19
- Shell脚本更新存储过程到数据库
- After changing the GCC version, make[1] appears in the compilation: cc: command not found
- 大厂镜像库
- Paper notes: graph neural network gat
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16
- Is there a case where sqlcdc monitors multiple tables and then associates them to sink to another table? All operations in MySQL
- Pat grade a 1033 to fill or not to fill
猜你喜欢
Déduisez la question d'aujourd'hui - 729. Mon emploi du temps I
一位博士在华为的22年
零基础自学STM32-复习篇2——使用结构体封装GPIO寄存器
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20
Which ecology is better, such as Mi family, graffiti, hilink, zhiting, etc? Analysis of five mainstream smart brands
2345文件粉碎,文件强力删除工具无捆绑纯净提取版
【无标题】数据库中一条查询SQL执行的过程
[untitled] a query SQL execution process in the database
3D drawing ()
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16
随机推荐
Pure QT version of Chinese chess: realize two-man, man-machine and network games
Building the prototype of library functions -- refer to the manual of wildfire
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 7
Structural theme model (I) STM package workflow
07 单件(Singleton)模式
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 14
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15
Six stone management: why should leaders ignore product quality
爬虫(9) - Scrapy框架(1) | Scrapy 异步网络爬虫框架
Blue Bridge Cup group B provincial preliminaries first question 2013 (Gauss Diary)
RobotFramework入门(二)appUI自动化之app启动
纯Qt版中国象棋:实现双人对战、人机对战及网络对战
Shell脚本更新存储过程到数据库
Bigder: I felt good about the 34/100 interview, but I didn't receive the admission
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 19
A copy can also produce flowers
2345 file shredding, powerful file deletion tool, unbound pure extract version
"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.3 linear algebra_ Learning thinking and exercise answers
Network Security Learning - Web vulnerabilities (Part 1)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8