lovely_fcukh

1.2万

AcWing2010
163.com
L_B_L

cpy2010

acwing_gza
Jill.

Katyusha
tamsl3skafut
yxc的小迷妹
markless_yjy

Andy2035
Hacker_King

lovely_fcukh
8小时前

lovely_fcukh
11小时前

# 特别说一点，结尾有彩蛋！！！

Code：

#include<iostream>
using namespace std;
int n,a[50005],f[50005],g[50005],ans,ma;
int main(){
while(cin>>a[++n]);
for(int i=1;i<=n;i++){
g[i]=1;
for(int j=1;j<i;j++)
if(a[j]>=a[i])f[i]=max(f[i],f[j]+1);else g[i]=max(g[i],g[j]+1);
ans=max(ans,f[i]);ma=max(ma,g[i]);
}cout<<ans<<endl<<ma;
return 0;
}


の需要多少个拦截系统呢，我们只需要将能拦截改为不能拦截即可。就是判读语句和可以拦截相反，这样就可以求出需要的拦截系统的数量。
Code：

#include<iostream>
using namespace std;
int n,a[50005],f[50005],c;
int main(){
while(cin>>a[++n]);
for(int i=1;i<n;i++){
int j=1;
while(j<=c&&a[i]<=f[j])j++;
if(j>c)f[++c]=a[i];
else f[j]=a[i];
}
cout<<c<<endl;
c=0;
for(int i=1;i<n;i++){
int j=1;
while(j<=c&&a[i]>f[j])j++;
if(j>c)f[++c]=a[i];
else f[j]=a[i];
}
cout<<c;
return 0;
}


Code：

#include<iostream>
#define int long long
using namespace std;
int n,a[500005],f[500005],c,x;
signed main(){
while(cin>>x)a[++n]=x;
f[0]=1e17;
for(int i=1;i<=n;i++){
if(a[i]<=f[c])f[++c]=a[i];
else{
int l=1,r=c;
while(l<r){
int mid=l+r>>1;
if(f[mid]<a[i])r=mid;
else l=mid+1;
}
f[l]=a[i];
}
}
cout<<c<<endl;
c=0;
f[0]=-1e17;
for(int i=1;i<=n;i++){
if(a[i]>f[c])f[++c]=a[i];
else{
int l=1,r=c;
while(l<r){
int mid=l+r>>1;
if(f[mid]>=a[i])r=mid;
else l=mid+1;
}
f[l]=a[i];
}
}
cout<<c;
return 0;
}


# 彩蛋（20分钟）保证主函数只有下划线、逗号和括号！！！优雅，太优雅了！！！！！！！

#include<iostream>
#define int long long
#define _ int
#define __ using
#define ___ namespace
#define ____ std
#define _____ n
#define ______ a
#define _______ f
const int N=500005,M=0,T=1e9,P=1;
#define ________ N
#define _________ c
#define __________ x
#define ___________ main
#define ____________ while
#define _____________ signed
#define ___________________________________________(a) cin>>a
#define ______________ M
#define _______________ T
#define ________________ P
#define _________________ for
#define __________________ i
#define ___________________ if
#define ____________________ else
#define _____________________ l
#define ______________________ r
#define _______________________ mid
#define _______________________________(a) cout<<a<<endl;
#define _______________________________________________(a,b) a=b
#define _________________________________________________(a,b) a<=b?1:0
#define __________________________________________________(a,b) a<b?1:0
#define ___________________________________________________(a,b) a>=b?1:0
#define ____________________________________________________(a,b) a>b?1:0
#define ______________________________________________________(a) ++a
#define ________________________________________________________(a,b) a+b
#define __________________________________________________________(a,b) a>>b
#define _______________________________________________________________(a) -a
#define _________________________________________________________________ return
__ ___ ____;
_ _____,______[________],_______[________],_________,__________;
_____________ ___________(){
____________(___________________________________________(__________))_______________________________________________(______[______________________________________________________(_____)],__________);
_______________________________________________(_______[______________],_______________);
_________________(_ _______________________________________________(__________________,________________);_________________________________________________(__________________,_____);______________________________________________________(__________________)){
___________________(_________________________________________________(______[__________________],_______[_________]))_______________________________________________(_______[______________________________________________________(_________)],______[__________________]);
____________________{
_ _______________________________________________(_____________________,________________),_______________________________________________(______________________,_________);
____________(__________________________________________________(_____________________,______________________)){
_ _______________________________________________(_______________________,__________________________________________________________(________________________________________________________(_____________________,______________________),________________));
___________________(__________________________________________________(_______[_______________________],______[__________________]))_______________________________________________(______________________,_______________________);
____________________ _______________________________________________(_____________________,________________________________________________________(_______________________,________________));
}
_______________________________________________(_______[_____________________],______[__________________]);
}
}
_______________________________(_________);
_______________________________________________(_________,______________);
_______________________________________________(_______[______________],_______________________________________________________________(_______________));
_________________(_ _______________________________________________(__________________,________________);_________________________________________________(__________________,_____);______________________________________________________(__________________)){
___________________(____________________________________________________(______[__________________],_______[_________]))_______________________________________________(_______[______________________________________________________(_________)],______[__________________]);
____________________{
_ _______________________________________________(_____________________,________________),_______________________________________________(______________________,_________);
____________(__________________________________________________(_____________________,______________________)){
_ _______________________________________________(_______________________,__________________________________________________________(________________________________________________________(_____________________,______________________),________________));
___________________(___________________________________________________(_______[_______________________],______[__________________]))_______________________________________________(______________________,_______________________);
____________________ _______________________________________________(_____________________,________________________________________________________(_______________________,________________));
}
_______________________________________________(_______[_____________________],______[__________________]);
}
}
_______________________________(_________);
_________________________________________________________________ ______________;
}


# 特別說一點，結尾有彩蛋！！！

Code：

#include<iostream>
using namespace std;
int n,a[50005],f[50005],g[50005],ans,ma;
int main(){
while(cin>>a[++n]);
for(int i=1;i<=n;i++){
g[i]=1;
for(int j=1;j<i;j++)
if(a[j]>=a[i])f[i]=max(f[i],f[j]+1);else g[i]=max(g[i],g[j]+1);
ans=max(ans,f[i]);ma=max(ma,g[i]);
}cout<<ans<<endl<<ma;
return 0;
}


の需要多少個攔截系統呢，我們只需要將能攔截改為不能攔截即可。就是判讀語句和可以攔截相反，這樣就可以求出需要的攔截系統的數量。
Code：

#include<iostream>
using namespace std;
int n,a[50005],f[50005],c;
int main(){
while(cin>>a[++n]);
for(int i=1;i<n;i++){
int j=1;
while(j<=c&&a[i]<=f[j])j++;
if(j>c)f[++c]=a[i];
else f[j]=a[i];
}
cout<<c<<endl;
c=0;
for(int i=1;i<n;i++){
int j=1;
while(j<=c&&a[i]>f[j])j++;
if(j>c)f[++c]=a[i];
else f[j]=a[i];
}
cout<<c;
return 0;
}


Code：

#include<iostream>
#define int long long
using namespace std;
int n,a[500005],f[500005],c,x;
signed main(){
while(cin>>x)a[++n]=x;
f[0]=1e17;
for(int i=1;i<=n;i++){
if(a[i]<=f[c])f[++c]=a[i];
else{
int l=1,r=c;
while(l<r){
int mid=l+r>>1;
if(f[mid]<a[i])r=mid;
else l=mid+1;
}
f[l]=a[i];
}
}
cout<<c<<endl;
c=0;
f[0]=-1e17;
for(int i=1;i<=n;i++){
if(a[i]>f[c])f[++c]=a[i];
else{
int l=1,r=c;
while(l<r){
int mid=l+r>>1;
if(f[mid]>=a[i])r=mid;
else l=mid+1;
}
f[l]=a[i];
}
}
cout<<c;
return 0;
}


# 彩蛋（20分鐘）保證主函數只有下劃線、逗號和括號！！！優雅，太優雅了！！！！！！！

#include<iostream>
#define int long long
#define _ int
#define __ using
#define ___ namespace
#define ____ std
#define _____ n
#define ______ a
#define _______ f
const int N=500005,M=0,T=1e9,P=1;
#define ________ N
#define _________ c
#define __________ x
#define ___________ main
#define ____________ while
#define _____________ signed
#define ___________________________________________(a) cin>>a
#define ______________ M
#define _______________ T
#define ________________ P
#define _________________ for
#define __________________ i
#define ___________________ if
#define ____________________ else
#define _____________________ l
#define ______________________ r
#define _______________________ mid
#define _______________________________(a) cout<<a<<endl;
#define _______________________________________________(a,b) a=b
#define _________________________________________________(a,b) a<=b?1:0
#define __________________________________________________(a,b) a<b?1:0
#define ___________________________________________________(a,b) a>=b?1:0
#define ____________________________________________________(a,b) a>b?1:0
#define ______________________________________________________(a) ++a
#define ________________________________________________________(a,b) a+b
#define __________________________________________________________(a,b) a>>b
#define _______________________________________________________________(a) -a
#define _________________________________________________________________ return
__ ___ ____;
_ _____,______[________],_______[________],_________,__________;
_____________ ___________(){
____________(___________________________________________(__________))_______________________________________________(______[______________________________________________________(_____)],__________);
_______________________________________________(_______[______________],_______________);
_________________(_ _______________________________________________(__________________,________________);_________________________________________________(__________________,_____);______________________________________________________(__________________)){
___________________(_________________________________________________(______[__________________],_______[_________]))_______________________________________________(_______[______________________________________________________(_________)],______[__________________]);
____________________{
_ _______________________________________________(_____________________,________________),_______________________________________________(______________________,_________);
____________(__________________________________________________(_____________________,______________________)){
_ _______________________________________________(_______________________,__________________________________________________________(________________________________________________________(_____________________,______________________),________________));
___________________(__________________________________________________(_______[_______________________],______[__________________]))_______________________________________________(______________________,_______________________);
____________________ _______________________________________________(_____________________,________________________________________________________(_______________________,________________));
}
_______________________________________________(_______[_____________________],______[__________________]);
}
}
_______________________________(_________);
_______________________________________________(_________,______________);
_______________________________________________(_______[______________],_______________________________________________________________(_______________));
_________________(_ _______________________________________________(__________________,________________);_________________________________________________(__________________,_____);______________________________________________________(__________________)){
___________________(____________________________________________________(______[__________________],_______[_________]))_______________________________________________(_______[______________________________________________________(_________)],______[__________________]);
____________________{
_ _______________________________________________(_____________________,________________),_______________________________________________(______________________,_________);
____________(__________________________________________________(_____________________,______________________)){
_ _______________________________________________(_______________________,__________________________________________________________(________________________________________________________(_____________________,______________________),________________));
___________________(___________________________________________________(_______[_______________________],______[__________________]))_______________________________________________(______________________,_______________________);
____________________ _______________________________________________(_____________________,________________________________________________________(_______________________,________________));
}
_______________________________________________(_______[_____________________],______[__________________]);
}
}
_______________________________(_________);
_________________________________________________________________ ______________;
}


# 这就是一道披着紫皮的红，看得懂也别给赞

Code：

//没压，我真没压，这怎么叫压行
#include<bits/stdc++.h>
using namespace std;
int n,m,k,l,cnt,p[205][205];//行数、列数、每条蛇的操作数、蛇的数量、剩余食物总数
char c[205][205],s[25][105];//地图、操作方向
struct o{
struct t{
int x,y;//蛇的所有部位的行数与列数
}ak[205];
int l,nb;//蛇的长度、蛇的编号
}a[25];
void dfs(int x,int y){
p[x][y]=1;
if(c[x+1][y]=='#'&&!p[x+1][y])a[l].ak[++a[l].l]={x+1,y},dfs(x+1,y);//记录此时的坐标,往下继续搜
if(c[x][y+1]=='#'&&!p[x][y+1])a[l].ak[++a[l].l]={x,y+1},dfs(x,y+1);//同上,往右继续搜
if(c[x-1][y]=='#'&&!p[x-1][y])a[l].ak[++a[l].l]={x-1,y},dfs(x-1,y);//同上,往上继续搜
if(c[x][y-1]=='#'&&!p[x][y-1])a[l].ak[++a[l].l]={x,y-1},dfs(x,y-1);//同上,往左继续搜
}
void dfs4(int snb,int x){
c[a[snb].ak[a[snb].l].x][a[snb].ak[a[snb].l].y]='.';//将蛇尾改为路
if(a[snb].l>1)c[a[snb].ak[1].x][a[snb].ak[1].y]='#';//如果这条蛇有蛇身，那么蛇头改为蛇身
for(int i=a[snb].l;i>=2;i--)a[snb].ak[i]=a[snb].ak[i-1];//此时蛇的这个部位移动到了它前一个部位的位置
if(x==1)a[snb].ak[1].x--;//如果是1向上走
if(x==2)a[snb].ak[1].x++;//如果是2向下走
if(x==3)a[snb].ak[1].y--;//如果是3向左走
if(x==4)a[snb].ak[1].y++;//如果是4向右走
c[a[snb].ak[1].x][a[snb].ak[1].y]='@';//更新蛇头
}
void dfs5(int snb,int x,int y){
for(int i=1;i<=a[snb].l;i++)c[a[snb].ak[i].x][a[snb].ak[i].y]='&';//将这条蛇改为食物
a[snb].l=0;//将这条蛇的长度清零
}
void dfs2(int snb,int x,int y,char zt){
if(zt=='W'&&c[x-1][y]!='#'&&c[x-1][y]!='@'&&x-1>0){
if(c[x-1][y]=='&'){//如果下一步是食物，将食物设为蛇头，原先的蛇头设为蛇身，蛇的长度加1
c[x][y]='#',c[x-1][y]='@',a[snb].l++;
for(int i=a[snb].l;i>=2;i--)a[snb].ak[i]=a[snb].ak[i-1];
a[snb].ak[1]={x-1,y};
}else dfs4(snb,1);//否则蛇直接向下一步进一
}else if(zt=='S'&&c[x+1][y]!='#'&&c[x+1][y]!='@'&&x+1<=n){
if(c[x+1][y]=='&'){//思路同上
c[x][y]='#',c[x+1][y]='@',a[snb].l++;
for(int i=a[snb].l;i>=2;i--)a[snb].ak[i]=a[snb].ak[i-1];
a[snb].ak[1]={x+1,y};
}else dfs4(snb,2);//思路同上
}else if(zt=='A'&&c[x][y-1]!='#'&&c[x][y-1]!='@'&&y-1>0){
if(c[x][y-1]=='&'){//思路同上
c[x][y]='#',c[x][y-1]='@',a[snb].l++;
for(int i=a[snb].l;i>=2;i--)a[snb].ak[i]=a[snb].ak[i-1];
a[snb].ak[1]={x,y-1};
}else dfs4(snb,3);//思路同上
}else if(zt=='D'&&c[x][y+1]!='#'&&c[x][y+1]!='@'&&y+1<=m){
if(c[x][y+1]=='&'){//思路同上
c[x][y]='#',c[x][y+1]='@',a[snb].l++;
for(int i=a[snb].l;i>=2;i--)a[snb].ak[i]=a[snb].ak[i-1];
a[snb].ak[1]={x,y+1};
}else dfs4(snb,4);//思路同上
}else dfs5(snb,x,y);//否则就是这条蛇die了，将这条蛇的每一个身体部位包括蛇头设为食物
}
bool f(o x,o y){
if(x.l!=y.l)return x.l>y.l;//先按长度排序
return x.nb<y.nb;//长度相同按编号排序
}
int main(){
cin>>n>>m>>k;//输入地图行数列数还有每条蛇的操作数
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>c[i][j];//输入地图
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(c[i][j]=='@')a[++l].ak[++a[l].l]={i,j},a[l].nb=l,dfs(i,j);//如果搜索到蛇头，那么蛇的数量加1，记录蛇头所在的位置以及它的编号，搜索蛇的身体
for(int i=1;i<=l;i++)for(int j=1;j<=k;j++)cin>>s[i][j];//输入每条蛇的操作
for(int i=1;i<=k;i++)for(int j=1;j<=l;j++)if(a[j].l)dfs2(j,a[j].ak[1].x,a[j].ak[1].y,s[j][i]);//对第j条蛇从蛇头开始每一次从编号大到小对蛇移动方向进行操作s[i][j]
sort(a+1,a+1+l,f);//给蛇的长度和编号排序
for(int i=1;i<=l;i++)cout<<a[i].l<<' '<<a[i].nb<<endl;//输出每条蛇的长度和编号
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(c[i][j]=='&')cnt++;//如果找到食物，cnt加1
cout<<cnt;//输出剩余食物总数
return 0;
}