


Codeforces Round #277.5 (Div. 2) Solution Report_html/css_WEB-ITnose
Still only know 4. . sad. . .
A: SwapSort
Use an array to store the sorted data. Then start from the beginning and swap what needs to be swapped with what should be at this position, up to n-1 times.
The code is as follows;
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;int a[4000], b[4000], c[4000], d[4000];int main(){ int i, j, n, pos, cnt; while(scanf("%d",&n)!=EOF) { cnt=0; for(i=0;i<n;i++) { scanf("%d",&a[i]); b[i]=a[i]; } sort(b,b+n); for(i=0;i<n;i++) { if(a[i]!=b[i]) { for(j=i+1;j<n;j++) { if(a[j]==b[i]) { pos=j; break; } } swap(a[i],a[pos]); c[cnt]=i;d[cnt++]=pos; } } printf("%d\n",cnt); for(i=0;i<cnt;i++) { printf("%d %d\n",c[i],d[i]); } } return 0;}
B: BerSU Ball
Bipart graph maximum matching naked question.
The code is as follows:
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;int link[200], vis[200], n, m, a[200], b[200];int head[200], cnt;struct node{ int u, v, next;}edge[100000];void add(int u, int v){ edge[cnt].v=v; edge[cnt].next=head[u]; head[u]=cnt++;}int dfs(int u){ int i; for(i=head[u];i!=-1;i=edge[i].next) { int v=edge[i].v; if(!vis[v]) { vis[v]=1; if(link[v]==-1||dfs(link[v])) { link[v]=u; return 1; } } } return 0;}void hungary(){ int i, ans=0; memset(link,-1,sizeof(link)); for(i=0;i<n;i++) { memset(vis,0,sizeof(vis)); if(dfs(i)) ans++; } printf("%d\n",ans);}int main(){ int i, j; while(scanf("%d",&n)!=EOF) { for(i=0;i<n;i++) { scanf("%d",&a[i]); } scanf("%d",&m); for(i=0;i<m;i++) { scanf("%d",&b[i]); } memset(head,-1,sizeof(head)); cnt=0; for(i=0;i<n;i++) { for(j=0;j<m;j++) { if(abs(a[i]-b[j])<=1) { add(i,j); } } } hungary(); } return 0;}
C: Given Length and Sum of Digits...
Greedy water problem.
Fill in order.
The code is as follows:
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL __int64const int INF=0x3f3f3f3f;int a[1000], b[1000];int main(){ int m, s, i, j, x; while(scanf("%d%d",&m,&s)!=EOF) { if(m*9<s) { printf("-1 -1\n"); continue ; } if(s==0) { if(m==1) printf("0 0\n"); else printf("-1 -1\n"); continue ; } x=s-1; for(i=m; i>=2; i--) { if(x>=9) { a[i]=9; x-=9; } else if(x>=0&&x<9) { a[i]=x; x=0; } } a[1]=x+1; x=s; for(i=1;i<=m;i++) { if(x>=9) { b[i]=9; x-=9; } else if(x>=0&&x<9) { b[i]=x; x=0; } } for(i=1;i<=m;i++) { printf("%d",a[i]); } printf(" "); for(i=1;i<=m;i++) { printf("%d",b[i]); } puts(""); } return 0;}
D: Unbearable Controversy of Being
Enumerate the points and perform BFS to find the distance is 2 point, and then record the number of times it reaches this point. If the number is greater than 2, it means it exists. Solve it based on the number of combinations.
The code is as follows:
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL __int64LL vis[4000], ans;int head[4000], cnt, n;struct node{ int u, v, next;}edge[50000];void add(int u,int v){ edge[cnt].v=v; edge[cnt].next=head[u]; head[u]=cnt++;}void bfs(int x){ int i; queue<int>q; for(i=head[x];i!=-1;i=edge[i].next) { q.push(edge[i].v); } while(!q.empty()) { int u=q.front(); q.pop(); for(i=head[u];i!=-1;i=edge[i].next) { int v=edge[i].v; if(v!=x) vis[v]++; } } for(i=1;i<=n;i++) { if(vis[i]>=2) ans+=vis[i]*(vis[i]-1)/2; }}int main(){ int m, i, j, u, v; scanf("%d%d",&n,&m); ans=0; memset(head,-1,sizeof(head)); cnt=0; while(m--) { scanf("%d%d",&u,&v); add(u,v); } for(i=1;i<=n;i++) { memset(vis,0,sizeof(vis)); bfs(i); } printf("%I64d\n",ans); return 0;}

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

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.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

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.
