当前位置:网站首页>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");
}
}
边栏推荐
- High number_ Vector algebra_ Unit vector_ Angle between vector and coordinate axis
- 好用的 JS 脚本
- Network Security Learning - Web vulnerabilities (Part 1)
- 3D drawing ()
- 2022.02.13
- 550 permission denied occurs when FTP uploads files, which is not a user permission problem
- Follow the mouse's angle and keyboard events
- MySQL winter vacation self-study 2022 11 (9)
- Redis skip table
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12
猜你喜欢
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8
Which ecology is better, such as Mi family, graffiti, hilink, zhiting, etc? Analysis of five mainstream smart brands
Referenceerror: primordials is not defined error resolution
Httprunnermanager installation (III) - configuring myql Database & initialization data under Linux
"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.5 automatic differentiation_ Learning thinking and exercise answers
Building the prototype of library functions -- refer to the manual of wildfire
RobotFramework入门(二)appUI自动化之app启动
How to accurately identify master data?
解决:AttributeError: ‘str‘ object has no attribute ‘decode‘
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9
随机推荐
Data preparation
Crawler (9) - scrape framework (1) | scrape asynchronous web crawler framework
2345文件粉碎,文件强力删除工具无捆绑纯净提取版
The third level of C language punch in
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15
Differences and usage scenarios between TCP and UDP
RobotFramework入门(一)简要介绍及使用
Li Kou today's question -729 My schedule I
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8
Patch NTP server at the beginning of DDoS counterattack
故障分析 | MySQL 耗尽主机内存一例分析
Httprunnermanager installation (III) - configuring myql Database & initialization data under Linux
事故指标统计
Advanced technology management - what is the physical, mental and mental strength of managers
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9
Zero basic self-study STM32 wildfire review of GPIO use absolute address to operate GPIO
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 11
Pat grade a 1033 to fill or not to fill
There are so many giants, why should we independently develop POS store cashier system?
Zero foundation self-study STM32 - Review 2 - encapsulating GPIO registers with structures