Codeforces Round #FF (Div. 1)-A,B,C_html/css_WEB-ITnose
A:DZY Loves Sequences
I read the wrong question at first. . sad.
The question is very simple and the method is also very simple. Just DP it.
dp[i][0]: The length obtained without any number change to the current position.
dp[i][1]: Go to the current position, change a number, and get the length
But you need to find it once in the forward direction, and then in the reverse direction.
#include<iostream>#include<stdio.h>#include<algorithm>#include<stdlib.h>#include<string.h>using namespace std;#define maxn 110000int dp[maxn][3];int num[maxn];int a[maxn];int n;void dos(int maxx){ memset(dp,0,sizeof(dp)); memset(num,-1,sizeof(num)); for(int i=n; i>=1; i--) { if(a[i]<a[i+1]) { dp[i][0]=dp[i+1][0]+1; } else { dp[i][0]=1; } dp[i][1]=dp[i][0]; num[i]=a[i]; if(a[i]<num[i+1]) { if(dp[i][1]<dp[i+1][1]+1) { dp[i][1]=dp[i+1][1]+1; num[i]=a[i]; } } if(a[i]>=a[i+1]) { if(dp[i][1]<dp[i+1][0]+1) { dp[i][1]=dp[i+1][0]+1; num[i]=a[i+1]-1; } } } for(int i=1; i<=n; i++) { //cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<num[i]<<endl; maxx=max(maxx,dp[i][0]); maxx=max(maxx,dp[i][1]); } cout<<maxx<<endl;}int main(){ while(~scanf("%d",&n)) { for(int i=1; i<=n; i++) { scanf("%d",&a[i]); } memset(dp,0,sizeof(dp)); memset(num,-1,sizeof(num)); for(int i=1; i<=n; i++) { if(a[i]>a[i-1]) { dp[i][0]=dp[i-1][0]+1; } else { dp[i][0]=1; } dp[i][1]=dp[i][0]; num[i]=a[i]; if(a[i]>num[i-1]) { if(dp[i][1]<dp[i-1][1]+1) { dp[i][1]=dp[i-1][1]+1; num[i]=a[i]; } } if(a[i]<=a[i-1]) { if(dp[i][1]<dp[i-1][0]+1) { dp[i][1]=dp[i-1][0]+1; num[i]=a[i-1]+1; } } } int maxx=-1; for(int i=1; i<=n; i++) { // cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<num[i]<<endl; maxx=max(maxx,dp[i][0]); maxx=max(maxx,dp[i][1]); } dos(maxx); } return 0;}
We can find that when selecting a horizontal row, the size order of the vertical rows remains unchanged, but each vertical row decreases by p .
So we can enumerate and select x horizontal rows and y vertical rows.
#include<iostream>#include<stdio.h>#include<algorithm>#include<stdlib.h>#include<string.h>#include<queue>using namespace std;#define maxn 1100#define LL __int64int mp[maxn][maxn];int hh[maxn];int ll[maxn];LL ph[1100000];LL pl[1100000];priority_queue<int>que;int n,m,k,p;void chu(){ ph[0]=pl[0]=0; while(!que.empty())que.pop(); for(int i=1;i<=n;i++) { que.push(hh[i]); } for(int i=1;i<=k;i++) { int x=que.top(); que.pop(); ph[i]=ph[i-1]+(LL)x; x=x-p*m; que.push(x); } while(!que.empty())que.pop(); for(int i=1;i<=m;i++) { que.push(ll[i]); } for(int i=1;i<=k;i++) { int x=que.top(); que.pop(); pl[i]=pl[i-1]+(LL)x; x=x-p*n; que.push(x); }}int main(){ while(~scanf("%d%d%d%d",&n,&m,&k,&p)) { memset(hh,0,sizeof(hh)); memset(ll,0,sizeof(ll)); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { scanf("%d",&mp[i][j]); hh[i]+=mp[i][j]; ll[j]+=mp[i][j]; } } chu(); LL ans=pl[k]; for(int i=1;i<=k;i++) { LL x=(LL)i*(LL)(k-i); x=(LL)x*(LL)p; ans=max(ans,pl[k-i]+ph[i]-x); } cout<<ans<<endl; } return 0;}
Mainly two properties:
1, the addition of two Fibonacci numbers It’s still a Fibonacci sequence.
2. According to the first two terms of the Fibonacci sequence, the Fibonacci number at any position and the sum of the Fibonacci sequence of any length can be obtained in O(1) time.
The rest is a simple interval summation problem.
#include<stdio.h>#include<iostream>#include<stdlib.h>#include<string.h>#include<algorithm>#include<vector>#include<math.h>#include<map>#pragma comment(linker, "/STACK:1024000000,1024000000")using namespace std;#define mem(a,b) (memset(a),b,sizeof(a))#define lmin 1#define rmax n#define lson l,(l+r)/2,rt<<1#define rson (l+r)/2+1,r,rt<<1|1#define root lmin,rmax,1#define now l,r,rt#define int_now int l,int r,int rt#define INF 99999999#define LL __int64#define mod 1000000009#define eps 1e-6#define zero(x) (fabs(x)<eps?0:x)#define maxn 330000LL sum[maxn<<2];LL f1[maxn<<2];LL f2[maxn<<2];LL fib[maxn];LL look(int a,int b,int n){ if(n==1)return a; if(n==2)return b; return (a*fib[n-2]+b*fib[n-1])%mod;}LL suan(int a,int b,int n){ if(n==1)return a; if(n==2)return (a+b)%mod; return ((look(a,b,n+2)-b)%mod+mod)%mod;}void push_up(int_now){ sum[rt]=sum[rt<<1]+sum[rt<<1|1]; sum[rt]=sum[rt]%mod;}void push_down(int_now){ if(f1[rt]!=0) { LL ll,rr; ll=(l+r)/2-l+1; rr=r-(l+r)/2; LL x,y; x=f1[rt]; y=f2[rt]; f1[rt<<1]=(f1[rt<<1]+x)%mod; f2[rt<<1]=(f2[rt<<1]+y)%mod; sum[rt<<1]=(sum[rt<<1]+suan(x,y,ll))%mod; LL px,py; px=x;py=y; x=look(px,py,ll+1); y=look(px,py,ll+2); //cout<<x<<" "<<y<<" +"<<rr<<endl; f1[rt<<1|1]=(f1[rt<<1|1]+x)%mod; f2[rt<<1|1]=(f2[rt<<1|1]+y)%mod; sum[rt<<1|1]=(sum[rt<<1|1]+suan(x,y,rr))%mod; f1[rt]=f2[rt]=0; }}void creat(int_now){ sum[rt]=f1[rt]=f2[rt]=0; if(l!=r) { creat(lson); creat(rson); push_up(now); } else { scanf("%I64d",&sum[rt]); }}void updata(int ll,int rr,int_now){ if(ll>r||rr<l)return; if(ll<=l&&rr>=r) { f1[rt]+=fib[l-ll+1]; f2[rt]+=fib[l-ll+2]; sum[rt]+=suan(fib[l-ll+1],fib[l-ll+2],r-l+1); sum[rt]=(sum[rt]+mod)%mod; f1[rt]=f1[rt]%mod; f2[rt]=f2[rt]%mod; return; } push_down(now); updata(ll,rr,lson); updata(ll,rr,rson); push_up(now);}LL query(int ll,int rr,int_now){ if(ll>r||rr<l)return 0; /// cout<<l<<"-"<<r<<" "<<sum[rt]<<endl; if(ll<=l&&rr>=r)return sum[rt]; push_down(now); return (query(ll,rr,rson)+query(ll,rr,lson))%mod;}int main(){ fib[1]=1;fib[2]=1; for(int i=3;i<maxn;i++) { fib[i]=fib[i-1]+fib[i-2]; fib[i]=fib[i]%mod; } int n,m,k,l,r; while(~scanf("%d%d",&n,&m)) { creat(root); while(m--) { scanf("%d%d%d",&k,&l,&r); if(k==1)updata(l,r,root); else { printf("%I64d\n",query(l,r,root)); } } } 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











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 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 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 roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

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.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

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.

The article discusses the differences between HTML tags , , , and , focusing on their semantic vs. presentational uses and their impact on SEO and accessibility.
