


Codeforces Round #224 (Div. 2) D Brute force search plus memoization_html/css_WEB-ITnose
I have been reading the question for half a year, and my English is terrible. The meaning of the question is to place two chess pieces on the chessboard as the starting point, but the starting point cannot be on #, and then start moving according to the instructions in the picture, right ^Up v Down, when moving, you can only follow the instructions in the picture. If there is a # in front of you, you can walk in, but you can't walk anymore. The two chess pieces can't touch each other while walking, but they will both move in the end. It's okay to go to the same #, and if you can take infinite steps, output -1, for example >
I was trapped by the output of -1 at first, because in addition to... When writing dfs, the image is 2000 * 2000, which is a bit big. I didn’t expect reverse DFS. I have no choice but to perform a memory search. Let dis[i][j] represent the steps that can be taken from (i, j) as the starting point. The furthest number of steps, so that the time should be able to pass, and then enumerate each point as the starting point for in-depth search, here you can judge whether it is -1, because the picture is 2000 * 2000, so you can go up to 4000000 The number of moves, if two chess pieces move in tandem, will not exceed 8000000 at most, so you can set a maximum value MAXN = 8000000. Once the marked point is moved again, this value will be returned, and the judgment can be made. Whether it is -1,
After finding the maximum number of steps for each point as the starting point, start searching. If there are two points with the same maximum number of steps, and they do not collide during the walking process, then The maximum sum of steps is ans ans . If you can't find it, placing two chess pieces one after another will definitely be the optimal one, which is ans ans - 1. Okay, here is the implementation of the code. The deep search is a bit confusing,
const int MAXN = 8000000 + 55;char aa[2000 + 55][2000 + 55];int mp[2000 + 55][2000 + 55];int xx[5] = {-1,1,0,0};int yy[5] = {0,0,-1,1};int dis[2000 + 55][2000 + 55];bool vis[2000 + 55][2000 + 55];int bb[2000 + 55][2000 + 55];int n,m;int ans;void init() { memset(aa,0,sizeof(aa)); memset(mp,0,sizeof(mp)); memset(dis,-1,sizeof(dis)); memset(vis,0,sizeof(vis)); memset(bb,-1,sizeof(bb));}bool input() { while(scanf("%d %d",&n,&m) == 2) { for(int i=0;i<n scanf for j="0;j<m;j++)" if>')mp[i][j] = 3; } } return false; } return true;}bool isok(int x,int y) { if(x =n || y = m)return true; return false;}int dfs1(int x,int y) { if(isok(x,y))return 0; if(vis[x][y])return MAXN; if(dis[x][y] != -1) return dis[x][y]; vis[x][y] = 1; if(mp[x][y] == -1) { vis[x][y] = 0; dis[x][y] = 0; return 0; } else { int tmp = dfs1(x + xx[mp[x][y]],y + yy[mp[x][y]]) + 1; vis[x][y] = 0; dis[x][y] = tmp; return tmp; }}int dfs2(int x,int y,int cnt) { if(bb[x][y] != -1) { if(bb[x][y] == cnt && mp[x][y] != -1)return 0; return 1; } if(mp[x][y] == -1) { bb[x][y] = cnt; return 1; } else { bb[x][y] = cnt; return dfs2(x + xx[mp[x][y]],y + yy[mp[x][y]],cnt + 1); }}void cal() { ans = 0; int mark; for(int i=0;i<n for j="0;j<m;j++)" if int tmp="dfs1(i,j);">= MAXN){ans = MAXN;return;} ans = max(ans,tmp); } } if(ans == 0)return ; mark = 0; for(int i=0;i<n for j="0;j<m;j++)" if ans> 1){ans *= 2;return ;} } } } ans += (ans - 1);}void output() { if(ans >= MAXN)puts("-1"); else cout <br> <br> <p></p> </n></n></n>

Self-closingtagsinHTMLandXMLaretagsthatclosethemselveswithoutneedingaseparateclosingtag,simplifyingmarkupstructureandenhancingcodingefficiency.1)TheyareessentialinXMLforelementswithoutcontent,ensuringwell-formeddocuments.2)InHTML5,usageisflexiblebutr

To build a website with powerful functions and good user experience, HTML alone is not enough. The following technology is also required: JavaScript gives web page dynamic and interactiveness, and real-time changes are achieved by operating DOM. CSS is responsible for the style and layout of the web page to improve aesthetics and user experience. Modern frameworks and libraries such as React, Vue.js and Angular improve development efficiency and code organization structure.

Boolean attributes are special attributes in HTML that are activated without a value. 1. The Boolean attribute controls the behavior of the element by whether it exists or not, such as disabled disable the input box. 2.Their working principle is to change element behavior according to the existence of attributes when the browser parses. 3. The basic usage is to directly add attributes, and the advanced usage can be dynamically controlled through JavaScript. 4. Common mistakes are mistakenly thinking that values need to be set, and the correct writing method should be concise. 5. The best practice is to keep the code concise and use Boolean properties reasonably to optimize web page performance and user experience.

HTML code can be cleaner with online validators, integrated tools and automated processes. 1) Use W3CMarkupValidationService to verify HTML code online. 2) Install and configure HTMLHint extension in VisualStudioCode for real-time verification. 3) Use HTMLTidy to automatically verify and clean HTML files in the construction process.

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
