CF #269 DIV2 A,B,C,D_html/css_WEB-ITnose
A
http://codeforces.com/contest/471/problem/A
Problem-solving idea: Give you 6 numbers and ask if at least 4 numbers are equal. If not, output "Alien". If yes, look at the remaining two numbers. If they are equal, output "
Elephant",否则输出"
Bear";
<pre name="code" class="n">#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <set>#include <map>#include <list>#include <queue>#include <stack>#include <deque>#include <vector>#include <bitset>#include <cmath>#include <utility>#define Maxn 100005#define Maxm 1000005#define lowbit(x) x&(-x)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define PI acos(-1.0)#define make_pair MP#define LL long long #define Inf (1LL<<62)#define inf 0x3f3f3f3f#define re freopen("in.txt","r",stdin)#define wr freopen("out.txt","w",stdout)using namespace std;int main(){ int a[6],flag; //re;wr; while(~scanf("%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5])) { flag=0; sort(a,a+6); if(a[0]==a[1]&&a[2]==a[1]&&a[3]==a[2]) flag=1; if(a[1]==a[2]&&a[2]==a[3]&&a[3]==a[4]) flag=2; if(a[2]==a[3]&&a[3]==a[4]&&a[4]==a[5]) flag=3; if(flag==0) { puts("Alien"); continue; } if(flag==1) { if(a[4]==a[5]) { puts("Elephant"); continue; } else { puts("Bear"); continue; } } else if(flag==2) { if(a[0]==a[5]) { puts("Elephant"); continue; } else { puts("Bear"); continue; } } else { if(a[0]==a[1]) { puts("Elephant"); continue; } else { puts("Bear"); continue; } } } return 0;}
http://codeforces.com/contest/471/problem/B
解题思路:给你一个序列,问是否有三种不同的方法使它们按非减序排序,显然只有有2个相等的元素集合数大于等于2时或者有3个相等的元素的集合时才有解,有解的时候集合内排序一下,我写的很繁,导致后面的题目没写,整场就跪了
<pre name="code" class="n">#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <set>#include <map>#include <list>#include <queue>#include <stack>#include <deque>#include <vector>#include <bitset>#include <cmath>#include <utility>#define Maxn 100005#define Maxm 1000005#define lowbit(x) x&(-x)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define PI acos(-1.0)#define make_pair MP#define LL long long #define Inf (1LL<<62)#define inf 0x3f3f3f3f#define re freopen("in.txt","r",stdin)#define wr freopen("out.txt","w",stdout)using namespace std;struct Mask{ int dif; int id; friend bool operator <(Mask a,Mask b) { if(a.dif!=b.dif) return a.dif<b.dif; else return a.id<b.id; }};int main(){ int n,m[2005],cnt,i,j; bool flag; Mask arr[2005]; //re;wr; while(~scanf("%d",&n)) { flag=false; cnt=0; memset(m,0,sizeof(m)); for(i=1;i<=n;i++) { scanf("%d",&arr[i].dif); m[arr[i].dif]++; arr[i].id=i; } for(i=0;i<=2000;i++) { if(m[i]>2) { flag=true; break; } if(m[i]==2) cnt++; } if(flag||cnt>=2) { puts("YES"); sort(arr+1,arr+1+n); if(flag) { for(i=1;i<=n;i++) { if(m[arr[i].dif]>2) break; } int a=arr[i].id; int b=arr[i+1].id; int c=arr[i+2].id; //cout<<a<<b<<c<<endl; for(j=1;j<=n;j++) { //cout<<j<<endl; if(j<i||j>i+2) { printf("%d%c",arr[j].id,j==n?'\n':' '); } else if(i==n-2) { printf("%d %d %d\n",a,b,c); j+=2; } else { printf("%d %d %d ",a,b,c); j+=2; } } for(j=1;j<=n;j++) { if(j<i||j>i+2) { printf("%d%c",arr[j].id,j==n?'\n':' '); } else if(i==n-2) { printf("%d %d %d\n",b,a,c); j+=2; } else { printf("%d %d %d ",b,a,c); j+=2; } } for(j=1;j<=n;j++) { if(j<i||j>i+2) { printf("%d%c",arr[j].id,j==n?'\n':' '); } else if(i==n-2) { printf("%d %d %d\n",c,b,a); j+=2; } else { printf("%d %d %d ",c,b,a); j+=2; } } } else { int f1,f2; for(i=1;i<=n;i++) if(m[arr[i].dif]==2) { f1=i; break; } for(i=i+2;i<=n;i++) if(m[arr[i].dif]==2) { f2=i; break; } int a=arr[f1].id; int b=arr[f1+1].id; int c=arr[f2].id; int d=arr[f2+1].id; //cout<<a<<b<<c<<d<<endl; //cout<<f1<<f2<<endl; for(i=1;i<=n;i++) { if((i<f1||i>f1+1)&&(i<f2||i>f2+1)) printf("%d%c",arr[i].id,i==n?'\n':' '); else if(i>=f1&&i<=f1+1) { printf("%d %d ",a,b); i+=1; } else if(i>=f2&&i<=f2+1) { if(f2==n-1) printf("%d %d\n",c,d); else printf("%d %d ",c,d); i+=1; } } for(i=1;i<=n;i++) { if((i<f1||i>f1+1)&&(i<f2||i>f2+1)) printf("%d%c",arr[i].id,i==n?'\n':' '); else if(i>=f1&&i<=f1+1) { printf("%d %d ",a,b); i+=1; } else if(i>=f2&&i<=f2+1) { if(f2==n-1) printf("%d %d\n",d,c); else printf("%d %d ",d,c); i+=1; } } for(i=1;i<=n;i++) { if((i<f1||i>f1+1)&&(i<f2||i>f2+1)) printf("%d%c",arr[i].id,i==n?'\n':' '); else if(i>=f1&&i<=f1+1) { printf("%d %d ",b,a); i+=1; } else if(i>=f2&&i<=f2+1) { if(f2==n-1) printf("%d %d\n",c,d); else printf("%d %d ",c,d); i+=1; } } } } else { puts("NO"); continue; } }}
http://codeforces.com/contest/471/problem/C
Problem-solving idea: first divide n sticks into two to build up to how many layers, and then start enumerating from 1. Note that the number of each layer is one For an arithmetic sequence with a tolerance of 3, just judge whether this layer can meet the needs of n
<pre name="code" class="n">#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <set>#include <map>#include <list>#include <queue>#include <stack>#include <deque>#include <vector>#include <bitset>#include <cmath>#include <utility>#define Maxn 100005#define Maxm 1000005#define lowbit(x) x&(-x)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define PI acos(-1.0)#define make_pair MP#define LL long long #define Inf (1LL<<62)#define inf 0x3f3f3f3f#define re freopen("in.txt","r",stdin)#define wr freopen("out.txt","w",stdout)using namespace std;LL cal(LL n){ return (3*n+1)*n/2;}LL calc(LL a,LL k,LL n){ return a+(n-1)*k;}int main(){ LL n,ans; //re;wr; while(~scanf("%I64d",&n)) { ans=0; LL l=0,r=(Maxm<<1),lv; while(r>=l) { LL m=(l+r)>>1; if(cal(m)<=n) { lv=m; l=m+1; } else r=m-1; } for(LL i=1;i<=lv;i++) { LL a=cal(i); if((n-a)%3==0) ans++; } printf("%d\n",ans); } return 0;}
<strong>http://codeforces.com/problemset/problem/471/D</strong>
<strong>解题思路:做出两个数列的相邻两项的差分数列,KMP判断短的差分数列在长的差分数列中出现几次即可,特判n=1和w=1的情况</strong>
<strong></strong><pre name="code" class="n">#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <set>#include <map>#include <list>#include <queue>#include <stack>#include <deque>#include <vector>#include <bitset>#include <cmath>#include <utility>#define Maxn 100005#define Maxm 1000005#define lowbit(x) x&(-x)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define PI acos(-1.0)#define make_pair MP#define LL long long #define Inf (1LL<<62)#define inf 0x3f3f3f3f#define re freopen("in.txt","r",stdin)#define wr freopen("out.txt","w",stdout)using namespace std;int next[Maxn<<1];void get_next(int *arr,int len){ int j=0,k=-1; next[0]=-1; while(j<=len) { if(k==-1||arr[j]==arr[k]) { j++;k++; next[j]=k; } else k=next[k]; }}int kmp(int *a,int *b,int l1,int l2){ get_next(a,l1); get_next(b,l2); int i=0,j=0,ans=0; while(i<l1) { if(j==-1||a[i]==b[j]) { i++;j++; } else j=next[j]; if(j==l2) { j=next[j]; ans++; } } return ans;}int a[Maxn<<1],b[Maxn<<1],ca[Maxn<<1],cb[Maxn<<1];int main(){ int m,n; //re;wr; while(~scanf("%d%d",&m,&n)) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(ca,0,sizeof(ca)); memset(cb,0,sizeof(cb)); for(int i=0;i<m;i++) { scanf("%d",a+i); if(i>=1) ca[i-1]=a[i]-a[i-1]; } for(int i=0;i<n;i++) { scanf("%d",b+i); if(i>=1) cb[i-1]=b[i]-b[i-1]; } if(m==1||n==1) { printf("%d\n",max(m,n)); continue; } printf("%d\n",m>=n?kmp(ca,cb,m-1,n-1):kmp(cb,ca,n-1,m-1)); } 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











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

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 is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

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