当前位置:网站首页>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;
}
边栏推荐
- Go language mutex lock
- Why is the resolution of the image generated by PHP GD library 96? How to change it to 72
- V3 02——What‘s new in Chrome extensions
- V3_ Chrome extended Chinese translation document V3 directory
- 2021-05-12
- Notes on reverse learning in the first week of winter vacation
- V3 01_ Welcome
- CCF command line options (Full Score code + problem solving ideas + skill summary) March 3, 2014
- Uniapp upload image method
- Fastcgi CGI shallow understanding
猜你喜欢

Ctfshow getting started with the web (ThinkPHP topic)

On simple code crawling Youdao translation_ 0's problem (to be solved)

CCF drawing (full mark code + problem solving ideas + skill summary) February 2, 2014
[email protected][])"/>NoViableAltException([email protected][])

How does hbuilder display in columns?
![[extensive reading of papers] multimodal attribute extraction](/img/ec/546c107ac0d31deded7ca94fdf0e2d.jpg)
[extensive reading of papers] multimodal attribute extraction

Summary of use of laravel DCAT admin

val_ Loss decreases first and then increases or does not decrease but only increases

Lihongyi machine learning 2020 homework summary

Laravel configures passport and returns token using JWT
随机推荐
Using docker to manage MySQL services under Windows
In situ merging of two arrays with two pointers
PHP reverses scenarios based on code and skillfully uses debug_ backtrace()
數據恢複軟件EasyRecovery15下載
PHP conditional operator
Minimum covering substring of two pointers
Double pointer circular linked list
ot initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicati
Laravel8 custom log directory, rename
PHP multidimensional array sorting
Fastcgi CGI shallow understanding
CCF drawing (full mark code + problem solving ideas + skill summary) February 2, 2014
2021-05-12
notepad正则删除关键词所在行
@Role of ResponseBody
Effect of shadow around the block after mouse over
CCF access control system (Full Score code + problem solving idea) 201412-1
Finding the root of an integer by dichotomy
Greedy interval problem (5)
Shangpinhui knowledge points of large e-commerce projects