当前位置:网站首页>CCF elimination games (Full Score code + problem solving ideas + skill summary) February 2, 2015
CCF elimination games (Full Score code + problem solving ideas + skill summary) February 2, 2015
2022-06-30 14:41:00 【A cute little monkey】
Skill summary
Sometimes thinking about a problem , want Think more from a computer perspective
Perhaps the point by point judgment process looks very ” stupid “, But normal thinking ” First judge whether the whole string should be eliminated , Then eliminate “ The code implementation of is more cumbersome
Title Description

Their thinking
- The data range of this question is not large , You can use pure simulated violence to solve problems
- To judge whether this series should be eliminated, we can think about whether the current point should be eliminated
- Move the pointer up, down, left and right from this point , When the values are equal , The pointer moves , Judge whether three or more are equal by pointer spacing
Code implementation
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 35;
int n, m;
int a[N][N];
bool b[N][N];
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i ++)
{
for (int j = 0; j < m; j ++)
{
cin >> a[i][j];
}
}
// Traverse every point , Determine whether it will be eliminated
for (int i = 0; i < n; i ++)
{
for (int j = 0; j < m; j ++)
{
int z = j, y = j, s = i, x = i; // Set up four pointers
while (z >= 0 && a[i][z] == a[i][j]) z --; // At the end of the cycle , The pointer points to the first position that does not meet the condition
while (y < m && a[i][y] == a[i][j]) y ++;
while (s >= 0 && a[s][j] == a[i][j]) s --;
while (x < n && a[x][j] == a[i][j]) x ++;
if (y - z >= 4 || x - s >= 4) b[i][j] = true; // for example 3,4,5 These three spaces are exactly the same color , Then the current pointer z = 2, y = 6, So it should be >= 4
// When there are three or more consecutive identical ones on the left, right, up and down , Then the point will be eliminated
}
}
for (int i = 0; i < n; i ++)
{
for (int j = 0; j < m; j ++)
{
if (!b[i][j]) cout << a[i][j] << " ";
else cout << 0 << " ";
}
cout << endl;
}
return 0;
}
边栏推荐
- Basic learning notes of C language
- Knowledge learned from the water resources institute project
- The first dark spring cup dnuictf
- Location of dichotomy
- org.json.JSONObject对象转json,json新增元素,根据json的key获取值。以及list对象格式字符串转jsonArray
- [extensive reading of papers] multi modal sarcasm detection and human classification in code mixed conversations
- Att & CK red team evaluation field (I)
- Laravel RBAC laravel permission use
- @PathVariable
- @Role of ResponseBody
猜你喜欢

CCF access control system (Full Score code + problem solving idea) 201412-1

Race of golang
![[buuctf] [actf2020 freshman competition]include](/img/42/50439290177fdea5f431e315cac1a1.jpg)
[buuctf] [actf2020 freshman competition]include

Attack and defense world web questions

1 figure to explain the difference and connection between nodejs and JS

Error on datetime when importing SQL file from MySQL
![[buuctf] [geek challenge 2019] secret file](/img/00/23bebd013eb4035555c0057725e3c4.jpg)
[buuctf] [geek challenge 2019] secret file

Knowledge learned from the water resources institute project

2021 geek challenge Web

Computer screenshot how to cut the mouse in
随机推荐
Go common lock mutex and rwmutex
org. json. The jsonobject object is converted to JSON, and JSON adds new elements. The value is obtained according to the JSON key. And list object format string to jsonarray
Four isolation levels of MySQL
Binary rotation array (2)
JS time conversion standard format, timestamp conversion standard format
PHP conditional operator
V3 01_ Welcome
Laravel artist command error
Computer screenshot how to cut the mouse in
ThinkPHP v3.2 comment annotation injection write shell
@PathVariable
2021-07-14 mybaitsplus
Shangpinhui knowledge points of large e-commerce projects
Component communication mode
2021-08-07 native and package types
Hbuilder most commonly used and full shortcut key set
go channel && select
【BUUCTF】 EasySql
Is it troublesome for CITIC futures to open an account? Is it safe? How much is the handling charge for opening an account for futures? Can you offer a discount
Vue returns to the previous page without refreshing the page / Vue caches the page