【Codeforces】Round #488 (Div. 2) 总结
【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) 总结的更多相关文章
- Codeforces Round #488 Div. 1
A:枚举每个点判断是否同时在两个正方形中即可. #include<iostream> #include<cstdio> #include<cmath> #inclu ...
- [Codeforces Round#488]Div.2
总结 这是我无聊透顶肝到三点半的一场 cf ,结果还真够无聊的 这套题涵盖了英语题,语文题,模拟题.注重考查了选手的英语素养能力,语文阅读能力和精湛的模拟和枚举能力.是不可多得的一套好题. 没什么单独 ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- 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 ...
- 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 ...
随机推荐
- htop 比top更好用的top
安装 sudo apt-get install htop 使用 htop
- FlatBuffer入门笔记
FlatBuffer入门笔记 1 flatbuffer资料 flatbuffer下载地址:https://github.com/google/flatbuffers flatbuffer官方使用文档: ...
- Java并发之synchronized深入
一句话总结synchronized: JVM会自动通过使用monitor来加锁和解锁,保证了同时只有一个线程可以执行指定代码,从而保证了线程安全,同时具有可重入和不可中断的性质. 一.synchron ...
- LeetCode第[88]题(Java):Merge Sorted Array(合并已排序数组)
题目:合并已排序数组 难度:Easy 题目内容: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as ...
- zDialog弹出层插件
效果图如下: 提取自ZCMS的弹出框: 代替window.open.window.alert.window.confirm:提供良好的用户体验: 水晶质感,设计细腻,外观漂亮: 兼容ie6/7/8.f ...
- PHP表单(get,post)提交方式
PHP 表单处理 PHP 超全局变量 $_GET 和 $_POST 用于收集表单数据(form-data). $_GET 是通过 URL 参数传递到当前脚本的变量数组. $_POST 是通过 HTTP ...
- bzoj1093: [ZJOI2007]最大半连通子图 scc缩点+dag上dp
一个有向图G=(V,E)称为半连通的(Semi-Connected),如果满足:?u,v∈V,满足u→v或v→u,即对于图中任意两点u,v,存在一条u到v的有向路径或者从v到u的有向路径.若G'=(V ...
- oracle 11g各种下载地址
Oracle Database 11g Release 2 Standard Edition and Enterprise Edition Software Downloadsoracle 数据库 1 ...
- 1-16-2 LVM管理和ssm存储管理器使用&磁盘配额
ssm存储管理器使用&磁盘配额 ssm存储管理器使用 系统存储管理器的使用 系统存储管理器(又称ssm,即system-storage-manager),是RHEL7/CentOS7新增的功能 ...
- yii2 的ActiveRecord
一 .查询 返回数组 $cond[] = "and";//条件数组需要加and,单一个字符串不需要加. $cond[] = "payTime >= '{$start ...