【Codeforces】Round #488 (Div. 2) 总结


比较僵硬的一场,还是手速不够,但是作为正式成为竞赛生的第一场比赛还是比较圆满的,起码没有FST,A掉ABCD,总排82,怒涨rating两百


A:Fingerprints



A题,就在第一个串中查找第二个串中的数字,最气的是一开始没编译直接交CE了,噗

#include<iostream>
#include<cstdio>
using namespace std;
int read(){
int ans=0,w=1;char c=getchar();
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')c=getchar(),w=-1;
while(isdigit(c))ans=ans*10+c-'0',c=getchar();
return ans*w;
}
#define N 20
int a[N],b[N];
int main(){
int n=read(),m=read();
for(int i=1;i<=n;i++)a[i]=read();
for(int j=1;j<=m;j++)b[j]=read();
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
if(a[i]==b[j]){
cout<<a[i]<<" ";
break;
}
}
return 0;
}

B:Knights of a Polygonal Table






B题,照样是手速题,按照能力值排一个序,然后可以用小根堆维护一下当前可以获得的最大价值,然后记录一下就好

#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL read(){
LL ans=0,w=1;char c=getchar();
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')c=getchar(),w=-1;
while(isdigit(c))ans=ans*10+c-'0',c=getchar();
return ans*w;
}
#define N 100010
struct Node{
LL p,c,id,ans;
}a[N];
LL n,k,ans[N];
priority_queue<LL,vector<LL>,greater<LL> > q;
bool cmp(Node a,Node b){
return a.p<b.p;
}
bool cmp2(Node a,Node b){
return a.id<b.id;
}
int main(){
LL sum=0;
n=read();k=read();
for(LL i=1;i<=n;i++)a[i].p=read();
for(LL i=1;i<=n;i++)a[i].c=read(),a[i].id=i;
sort(a+1,a+n+1,cmp);
for(LL i=1;i<=min(k+1,n);i++){
a[i].ans=a[i-1].ans+a[i].c;
q.push(a[i].c);
sum+=a[i].c;
}
for(LL i=k+2;i<=n;i++){
LL top=q.top();q.pop();
sum-=top;
q.push(a[i].c);
sum+=a[i].c;
a[i].ans=sum;
}
sort(a+1,a+n+1,cmp2);
for(LL i=1;i<=n;i++)
printf("%I64d ",a[i].ans);
return 0;
}

C:Two Squares










就是给你两个正方形,判断有没有相交

我把这种题叫做不用脑子却死一片

final test的时候有一大堆人这题fst了。。诶

把握好代码的细节,然后写几个特判就好了

#include<bits/stdc++.h>
using namespace std;
struct Node{
int x,y;
}a[5],b[5];
bool cmp(Node a,Node b){
if(a.x==b.x)return a.y<b.y;
return a.x<b.x;
}
int main(){
for(int i=1;i<=4;i++)scanf("%d%d",&a[i].x,&a[i].y);
for(int i=1;i<=4;i++)scanf("%d%d",&b[i].x,&b[i].y);
sort(a+1,a+5,cmp);
sort(b+1,b+5,cmp);
int tmp=0;
if(b[4].x<a[1].x)tmp=1;
if(b[2].y>a[2].y)tmp=1;
if(b[3].y<a[1].y)tmp=1;
if(b[1].x>a[3].x)tmp=1;
if(tmp){
printf("NO");
return 0;
}
//zuoshang
if(b[1].x<a[2].x&&b[3].y>a[2].y){
int t=b[2].y-b[2].x;
if(t+a[2].x>a[2].y)tmp=1;
}
//zuoxia
if(b[1].x<a[1].x&&b[2].y<a[1].y){
int t=b[3].x+b[3].y;
if(t-a[1].x<a[1].y)tmp=1;
}
//youshang
if(b[3].y>a[4].y&&b[4].x>a[4].x){
int t=b[1].x+b[1].y;
if(t-a[4].x>a[4].y)tmp=1;
}
//youxia
if(b[2].y<a[3].y&&b[4].x>a[3].x){
int t=b[3].y-b[3].x;
if(t+a[3].x<a[3].y)tmp=1;
}
if(tmp){
printf("NO");
return 0;
}
printf("YES");
return 0;
}

D:Open Communication






身为一个蒟蒻这种题我还是少碰的好,题意很毒瘤,然后我就用非常不正常的做法A了,我都不知道我是怎么A的。

大概是有两个无聊的人,他们互相传递数字对,让你确定他们的秘密数字是什么,然后秘密数字是:对于两个元素不完全相等数对,其中一个相等的元素

然后可以确定输出那个数,你不能确定但那两个人可以确定输出0,你和其中一人都不能确定输出-1

然后我就记录一下在每个人的信息里可能匹配的和全局可能匹配的,加一堆特判就好了,反正是乱搞做法

#include<bits/stdc++.h>
using namespace std;
#define N 30
struct Pai{
int a,b;
}x[N],y[N];
int n,m,pic[N];
int vis1[N][N],vis2[N][N];
int tmp1[N],tmp2[N];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>x[i].a>>x[i].b;
for(int i=1;i<=m;i++)cin>>y[i].a>>y[i].b;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
if(x[i].a==y[j].a&&x[i].b==y[j].b)continue;
if(x[i].a==y[j].b&&x[i].b==y[j].a)continue;
if(x[i].a==y[j].a||x[i].a==y[j].b)pic[x[i].a]=1,vis1[i][x[i].a]=1,vis2[j][x[i].a]=1;
if(x[i].b==y[j].a||x[i].b==y[j].b)pic[x[i].b]=1,vis1[i][x[i].b]=1,vis2[j][x[i].b]=1;
}
for(int i=1;i<=n;i++)
for(int j=1;j<=9;j++)tmp1[i]+=vis1[i][j];
for(int i=1;i<=m;i++)
for(int j=1;j<=9;j++)tmp2[i]+=vis2[i][j];
int siz=0,tip;
for(int i=1;i<=9;i++){
siz+=pic[i];
if(pic[i])tip=i;
}
if(siz==1){
cout<<tip;
return 0;
}
if(!siz){
cout<<"-1";
return 0;
}
for(int i=1;i<=n;i++){
if(tmp1[i]>1){
cout<<"-1";
return 0;
}
}
for(int i=1;i<=m;i++){
if(tmp2[i]>1){
cout<<"-1";
return 0;
}
}
cout<<"0";
return 0;
}

E:Careful Maneuvering




F:Compute Power



【Codeforces】Round #488 (Div. 2) 总结的更多相关文章

  1. Codeforces Round #488 Div. 1

    A:枚举每个点判断是否同时在两个正方形中即可. #include<iostream> #include<cstdio> #include<cmath> #inclu ...

  2. [Codeforces Round#488]Div.2

    总结 这是我无聊透顶肝到三点半的一场 cf ,结果还真够无聊的 这套题涵盖了英语题,语文题,模拟题.注重考查了选手的英语素养能力,语文阅读能力和精湛的模拟和枚举能力.是不可多得的一套好题. 没什么单独 ...

  3. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  4. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  5. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  6. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  7. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  8. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  9. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

随机推荐

  1. spring boot 知识点1

    spring boot: 1. 可以在pom文件中添加依赖sping-boot-properties-migrator来对项目进行升级,升级完成后,删除即可. 2. 关于日志的配置,参考:http:/ ...

  2. JDBC 的 PreparedStatement 与 Statement

    import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import ...

  3. 关于推荐库位 java前端与SQL语句后面的结合

    ----------------------------------------------------------------------------------- select a1.id,a1. ...

  4. Visual Studio 2013 Ultimate & IIS Express 8.0 错误 [iisexpress.exe”已退出,返回值为 -1073741816 (0xc0000008)] 解决方法

    1. 开发环境 Visual Studio 2013 Ultimate IIS 8.0 Express 2. 错误信息 错误提示:iisexpress.exe”已退出,返回值为 -1073741816 ...

  5. Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 离散化+逆元

    E. Mike and Geometry Problem time limit per test 3 seconds memory limit per test 256 megabytes input ...

  6. html和JavaScript,用户点击浏览器后退按钮,或者返回上一步自动刷新方式

    浏览器用户返回上一步,自动刷新 方式一. <input type="hidden" id="refreshed" value="no" ...

  7. Android 数据库 ObjectBox 源码解析

    一.ObjectBox 是什么? greenrobot 团队(现有 EventBus.greenDAO 等开源产品)推出的又一数据库开源产品,主打移动设备.支持跨平台,最大的优点是速度快.操作简洁,目 ...

  8. [spring]Bean注入——使用注解代替xml配置

    使用注解编程,主要是为了替代xml文件,使开发更加快速. 一.使用注解前提: <?xml version="1.0" encoding="UTF-8"?& ...

  9. Day34 设计模式

    参考博客: http://www.cnblogs.com/alex3714/articles/5760582.html 什么是设计模式 Christopher Alexander:“每一个模式描述了一 ...

  10. 前端开发必备 - Emmet

    介绍 Emmet (前身为 Zen Coding) 是一个能大幅度提高前端开发效率的一个工具. 基本上,大多数的文本编辑器都会允许你存储和重用一些代码块,我们称之为"片段".虽然片 ...