博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Beta Round #14 (Div. 2)
阅读量:4501 次
发布时间:2019-06-08

本文共 4515 字,大约阅读时间需要 15 分钟。

Codeforces Beta Round #14 (Div. 2)

A

 找最大最小的行列值即可

1 #include
2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 500005 7 typedef long long ll; 8 /*#ifndef ONLINE_JUDGE 9 freopen("1.txt","r",stdin);10 #endif */11 12 string str[55];13 14 int main(){15 #ifndef ONLINE_JUDGE16 freopen("1.txt","r",stdin);17 #endif18 std::ios::sync_with_stdio(false);19 int n,m;20 cin>>n>>m;21 int hangmin=105,hangmax=-1,liemin=105,liemax=-1;22 for(int i=0;i
>str[i];23 for(int i=0;i
View Code

 

B

水题

1 #include
2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 500005 7 typedef long long ll; 8 /*#ifndef ONLINE_JUDGE 9 freopen("1.txt","r",stdin);10 #endif */11 12 int n,x;13 int a[1005];14 15 int main(){16 #ifndef ONLINE_JUDGE17 // freopen("1.txt","r",stdin);18 #endif19 std::ios::sync_with_stdio(false);20 cin>>n>>x;21 int u,v;22 for(int i=1;i<=n;i++){23 cin>>u>>v;24 if(u>v) swap(u,v);25 a[u]++,a[v+1]--;26 }27 int ans=0x3f3f3f3f;28 int num=0;29 for(int i=0;i<=1001;i++){30 num+=a[i];31 if(num==n){32 ans=min(ans,abs(i-x));33 }34 }35 if(ans==0x3f3f3f3f) cout<<-1<
View Code

 

C

判断四条线段是否可以构成与坐标轴平行或垂直的正方形,感觉数据有点坑

1 #include
2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 500005 7 typedef long long ll; 8 /*#ifndef ONLINE_JUDGE 9 freopen("1.txt","r",stdin);10 #endif */11 12 map
,int>mp;13 map
,int>::iterator it;14 map< pair< pair
,pair
>,int >book;15 16 int main(){17 #ifndef ONLINE_JUDGE18 freopen("1.txt","r",stdin);19 #endif20 std::ios::sync_with_stdio(false);21 int a,b,c,d;22 int flag=0;23 for(int i=0;i<4;i++){24 cin>>a>>b>>c>>d;25 mp[make_pair(a,b)]++;26 mp[make_pair(c,d)]++;27 if(a==c&&b==d) flag=1;28 vector
>v;29 v.push_back(make_pair(a,b));30 v.push_back(make_pair(c,d));31 sort(v.begin(),v.end());32 if(book[make_pair(v[0],v[1])]==0){33 book[make_pair(v[0],v[1])]=1;34 }35 else{36 flag=1;37 }38 // cout<
<<" "<
<<" "<
<<" "<
<
second!=2){42 flag=1;43 }44 }45 if(flag){46 cout<<"NO"<
>ve;50 for(it=mp.begin();it!=mp.end();it++){51 ve.push_back(it->first);52 }53 sort(ve.begin(),ve.end());54 if(ve[0].first==ve[1].first&&ve[2].first==ve[3].first&&55 ve[0].second==ve[2].second&&ve[1].second==ve[3].second){56 cout<<"YES"<
View Code

 

D

枚举删边,然后跑dfs

1 #include
2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 500005 7 typedef long long ll; 8 /*#ifndef ONLINE_JUDGE 9 freopen("1.txt","r",stdin);10 #endif */11 12 int n;13 vector
ve[205];14 vector
>d;15 16 int r;17 18 int dfs(int pos,int pre){19 int len1=0,len2=0;20 int tmp=0;21 for(int i=0;i
len1){len2=len1,len1=r;}25 else{len2=max(len2,r);}26 }27 }28 tmp=max(tmp,len1+len2);29 r=len1+1;30 return tmp;31 }32 33 int main(){34 #ifndef ONLINE_JUDGE35 freopen("1.txt","r",stdin);36 #endif37 cin>>n;38 int a,b;39 for(int i=1;i
>a>>b;41 ve[a].push_back(b);42 ve[b].push_back(a);43 d.push_back(make_pair(a,b));44 }45 int ans=0;46 for(int i=0;i
View Code

 

E

DP,细节在代码里

1 #include
2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 500005 7 typedef long long ll; 8 /*#ifndef ONLINE_JUDGE 9 freopen("1.txt","r",stdin);10 #endif */11 12 ll dp[25][15][5][2];///分别表示第i个数,第j个尖峰数,尖峰高度和上升(1)或下降(0)13 14 int main(){15 #ifndef ONLINE_JUDGE16 // freopen("1.txt","r",stdin);17 #endif18 int n,m;19 for(int i=1;i<5;i++) dp[1][1][i][1]=1;20 for(int i=2;i<=20;i++){21 for(int j=1;j<=10;j++){22 for(int k=1;k<=4;k++){23 for(int l=1;l
>n>>m;39 ll ans=0;40 for(int i=1;i<=4;i++){41 ans+=dp[n][m][i][0];42 }43 cout<
<
View Code

 

转载于:https://www.cnblogs.com/Fighting-sh/p/10353837.html

你可能感兴趣的文章
解决:Cannot find ContentTypeReader HeightmapCollision.HeightMapInfoReader
查看>>
内存映射(Linux设备驱动程序)
查看>>
bzoj 5072
查看>>
[Luogu] 矩阵加速(数列)
查看>>
[LeetCode] Design Circular Queue 设计环形队列
查看>>
运动回调-链式运动
查看>>
素数---小修改1
查看>>
linux shell常用快捷键(转载)
查看>>
Ajax 跨域请求
查看>>
spring test---測试SpringMvc初识
查看>>
信息加密之消息摘要算法的MAC
查看>>
Docker 组件如何协作?- 每天5分钟玩转容器技术(8)
查看>>
js时间日期处理
查看>>
161117、使用spring声明式事务抛出 identifier of an instance of
查看>>
解决IE6-IE7下li上下间距
查看>>
勇于担当:好男人的三块责任田——
查看>>
小组冲刺第三天
查看>>
emqx配置mySql身份认证
查看>>
Mysql 中的伪列用法1
查看>>
springboot情操陶冶-web配置(七)
查看>>