Codeforces Round #281 (Div. 2) 解题报告 A.B.C.D.

2024-08-24 21:32

本文主要是介绍Codeforces Round #281 (Div. 2) 解题报告 A.B.C.D.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

A - Vasya and Football

纯模拟。。比较坑的是会有不符合足球常识的地方。。

代码如下:

#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 __int64
const int INF=0x3f3f3f3f;
struct node
{int num, time, f;char ah;
}fei[100];
int cmp(node x, node y)
{return x.time<y.time;
}
int foul(char c)
{if(c=='y') return 1;return 2;
}
int main()
{char s1[30], s2[30], c1, c2;int n, i, j, t, cnt=0, num, flag;scanf("%s%s",s1,s2);scanf("%d",&n);for(i=0;i<n;i++){scanf("%d %c %d %c",&t,&c1,&num,&c2);flag=0;for(j=0;j<cnt;j++){if(fei[j].ah==c1&&fei[j].num==num) {fei[j].f+=foul(c2);if(fei[j].f-foul(c2)<2)fei[j].time=t;flag=1;break;}}if(!flag){fei[cnt].num=num;fei[cnt].time=t;fei[cnt].ah=c1;fei[cnt++].f=foul(c2);}}sort(fei,fei+cnt,cmp);for(i=0;i<cnt;i++){if(fei[i].f>=2){if(fei[i].ah=='h') printf("%s ",s1);else printf("%s ",s2);printf("%d %d\n",fei[i].num,fei[i].time);}}return 0;
}

B - Vasya and Wrestling

水题。。先比较和然后再根据题意比较字典序即可。实在没啥好说的。。

代码如下:

#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 __int64
const int INF=0x3f3f3f3f;
LL a[210000], b[210000];
int main()
{LL cnt1=0, cnt2=0, n, x, s1=0, s2=0, t;int i;scanf("%I64d",&n);while(n--){scanf("%I64d",&x);if(x>0){a[cnt1++]=x;s1+=x;}else{b[cnt2++]=-x;s2-=x;}if(n==0) t=x>0?1:2;}if(s1>s2) printf("first\n");else if(s1<s2) printf("second\n");else{int flag=0;for(i=0;i<cnt1&&i<cnt2;i++){if(a[i]>b[i]){flag=1;break;}else if(a[i]<b[i]){flag=2;break;}}if(flag==1) puts("first");else if(flag==2) puts("second");else if(cnt1>cnt2) puts("first");else if(cnt1<cnt2) puts("second");else if(t==1) puts("first");else puts("second");}return 0;
}
C - Vasya and Basketball

也是一水题。。不过我直接跪了。。各种细节手残。。居然错了11次。。。。。中间还交到D题去了一次。。。

先把各种出现过的数存起来,排序,然后分别二分判断两人有多少个二分,有多少三分的,找最大值即可。

代码如下:

#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 __int64
const int INF=0x3f3f3f3f;
int a[210000], b[210000], n, m, c[420000], f[420000];
int bin_search(int d[], int x, int high)
{int low=1, mid, ans=0;while(low<=high) {mid=low+high>>1;if(d[mid]<=x) {ans=mid;low=mid+1;}else high=mid-1;}return ans;
}
int main()
{int i, j, aa, bb, max1=-2*1e9, x, y, z, cnt=1, p1, p2;scanf("%d",&n);for(i=1; i<=n; i++) {scanf("%d",&a[i]);c[i]=a[i];}scanf("%d",&m);for(i=1; i<=m; i++) {scanf("%d",&b[i]);c[i+n]=b[i];}sort(c+1,c+n+m+1);sort(a+1,a+n+1);sort(b+1,b+m+1);c[0]=0;f[0]=0;for(i=1;i<=n+m;i++){if(c[i]!=c[i-1]){f[cnt++]=c[i];}}for(i=0;i<cnt;i++){x=bin_search(a,f[i],n);y=bin_search(b,f[i],m);p1=x*2+(n-x)*3;p2=y*2+(m-y)*3;if(max1<p1-p2){max1=p1-p2;aa=p1;bb=p2;}}printf("%d:%d\n",aa,bb);return 0;
}


D - Vasya and Chess

猜想题、、所以我是猜的、、证明不会。。

代码如下:

#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 __int64
const int INF=0x3f3f3f3f;int main()
{int n;scanf("%d",&n);if(n%2==0)  printf("white\n1 2\n");elseprintf("black\n");return 0;
}


这篇关于Codeforces Round #281 (Div. 2) 解题报告 A.B.C.D.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1103658

相关文章

【专题】2024飞行汽车技术全景报告合集PDF分享(附原数据表)

原文链接: https://tecdat.cn/?p=37628 6月16日,小鹏汇天旅航者X2在北京大兴国际机场临空经济区完成首飞,这也是小鹏汇天的产品在京津冀地区进行的首次飞行。小鹏汇天方面还表示,公司准备量产,并计划今年四季度开启预售小鹏汇天分体式飞行汽车,探索分体式飞行汽车城际通勤。阅读原文,获取专题报告合集全文,解锁文末271份飞行汽车相关行业研究报告。 据悉,业内人士对飞行汽车行业

计算机毕业设计 大学志愿填报系统 Java+SpringBoot+Vue 前后端分离 文档报告 代码讲解 安装调试

🍊作者:计算机编程-吉哥 🍊简介:专业从事JavaWeb程序开发,微信小程序开发,定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事,生活就是快乐的。 🍊心愿:点赞 👍 收藏 ⭐评论 📝 🍅 文末获取源码联系 👇🏻 精彩专栏推荐订阅 👇🏻 不然下次找不到哟~Java毕业设计项目~热门选题推荐《1000套》 目录 1.技术选型 2.开发工具 3.功能

Codeforces Round #240 (Div. 2) E分治算法探究1

Codeforces Round #240 (Div. 2) E  http://codeforces.com/contest/415/problem/E 2^n个数,每次操作将其分成2^q份,对于每一份内部的数进行翻转(逆序),每次操作完后输出操作后新序列的逆序对数。 图一:  划分子问题。 图二: 分而治之,=>  合并 。 图三: 回溯:

Codeforces Round #261 (Div. 2)小记

A  XX注意最后输出满足条件,我也不知道为什么写的这么长。 #define X first#define Y secondvector<pair<int , int> > a ;int can(pair<int , int> c){return -1000 <= c.X && c.X <= 1000&& -1000 <= c.Y && c.Y <= 1000 ;}int m

Codeforces Beta Round #47 C凸包 (最终写法)

题意慢慢看。 typedef long long LL ;int cmp(double x){if(fabs(x) < 1e-8) return 0 ;return x > 0 ? 1 : -1 ;}struct point{double x , y ;point(){}point(double _x , double _y):x(_x) , y(_y){}point op

Codeforces Round #113 (Div. 2) B 判断多边形是否在凸包内

题目点击打开链接 凸多边形A, 多边形B, 判断B是否严格在A内。  注意AB有重点 。  将A,B上的点合在一起求凸包,如果凸包上的点是B的某个点,则B肯定不在A内。 或者说B上的某点在凸包的边上则也说明B不严格在A里面。 这个处理有个巧妙的方法,只需在求凸包的时候, <=  改成< 也就是说凸包一条边上的所有点都重复点都记录在凸包里面了。 另外不能去重点。 int

Codeforces 482B 线段树

求是否存在这样的n个数; m次操作,每次操作就是三个数 l ,r,val          a[l] & a[l+1] &......&a[r] = val 就是区间l---r上的与的值为val 。 也就是意味着区间[L , R] 每个数要执行 | val 操作  最后判断  a[l] & a[l+1] &......&a[r] 是否= val import ja

Python:豆瓣电影商业数据分析-爬取全数据【附带爬虫豆瓣,数据处理过程,数据分析,可视化,以及完整PPT报告】

**爬取豆瓣电影信息,分析近年电影行业的发展情况** 本文是完整的数据分析展现,代码有完整版,包含豆瓣电影爬取的具体方式【附带爬虫豆瓣,数据处理过程,数据分析,可视化,以及完整PPT报告】   最近MBA在学习《商业数据分析》,大实训作业给了数据要进行数据分析,所以先拿豆瓣电影练练手,网络上爬取豆瓣电影TOP250较多,但对于豆瓣电影全数据的爬取教程很少,所以我自己做一版。 目

开题报告中的研究方法设计:AI能帮你做什么?

AIPaperGPT,论文写作神器~ https://www.aipapergpt.com/ 大家都准备开题报告了吗?研究方法部分是不是已经让你头疼到抓狂? 别急,这可是大多数人都会遇到的难题!尤其是研究方法设计这一块,选定性还是定量,怎么搞才能符合老师的要求? 每次到这儿,头脑一片空白。 好消息是,现在AI工具火得一塌糊涂,比如ChatGPT,居然能帮你在研究方法这块儿上出点主意。是不

CSS实现DIV三角形

本文内容收集来自网络 #triangle-up {width: 0;height: 0;border-left: 50px solid transparent;border-right: 50px solid transparent;border-bottom: 100px solid red;} #triangle-down {width: 0;height: 0;bor