A:枚举每个点判断是否同时在两个正方形中即可。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
struct data
{
int x,y;
void get(){x=read();y=read();}
}a[4],b[4];
bool isin1(int x,int y)
{
int LEFT=1000,RIGHT=-1000,UP=-1000,DOWN=1000;
for (int i=0;i<4;i++)
LEFT=min(LEFT,a[i].x),
RIGHT=max(RIGHT,a[i].x),
UP=max(UP,a[i].y),
DOWN=min(DOWN,a[i].y);
if (LEFT<=x&&RIGHT>=x&&UP>=y&&DOWN<=y) return 1;
else return 0;
}
bool isin2(int x,int y)
{
int LEFT=1000,RIGHT=-1000,UP=-1000,DOWN=1000;
for (int i=0;i<4;i++)
LEFT=min(LEFT,b[i].x),
RIGHT=max(RIGHT,b[i].x),
UP=max(UP,b[i].y),
DOWN=min(DOWN,b[i].y);
int mid1=(LEFT+RIGHT)/2,mid2=(UP+DOWN)/2;
if (abs(x-mid1)+abs(y-mid2)<=mid1-LEFT) return 1;
else return 0;
}
void win(){cout<<"Yes";exit(0);}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif
for (int i=0;i<4;i++) a[i].get();
for (int i=0;i<4;i++) b[i].get();
for (int i=-100;i<=100;i++)
for (int j=-100;j<=100;j++)
if (isin1(i,j)&&isin2(i,j)) win();
cout<<"No";
return 0;
//NOTICE LONG LONG!!!!!
}

  B:莫名其妙的题。首先要知道这俩人只想知道他们的共同数字是什么,而不是对方的数字对是什么。先判断啥都不知道能否确定该数字,只要考虑每一对仅有一个数字相同的数对,如果其共同数字都相同,即可确定该数为答案。否则仍考虑每一对可能的数对,如果某一种情况下有一方无法确定共同数字,即输出-1。最后输出0即可。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 100
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int n,m;
struct data{int x,y;
}a[N],b[N];
int calc(data a,data b)
{
return (a.x==b.x)+(a.x==b.y)+(a.y==b.x)+(a.y==b.y);
}
int same(data a,data b)
{
if (a.x==b.x||a.x==b.y) return a.x;
else return a.y;
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif
n=read(),m=read();
for (int i=1;i<=n;i++)
{
a[i].x=read(),a[i].y=read();
if (a[i].x>a[i].y) swap(a[i].x,a[i].y);
}
for (int i=1;i<=m;i++)
{
b[i].x=read(),b[i].y=read();
if (b[i].x>b[i].y) swap(b[i].x,b[i].y);
}
int ans=0,uuu;
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
if (calc(a[i],b[j])==1) ans++,uuu=same(a[i],b[j]);
bool flag=0;
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
if (calc(a[i],b[j])==1&&same(a[i],b[j])!=uuu) flag=1;
if (!flag) {cout<<uuu;return 0;}
ans=0;
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
if (calc(a[i],b[j])==1)
{
for (int x=1;x<=n;x++)
if (calc(a[x],b[j])==1&&same(a[x],b[j])!=same(a[i],b[j])) {cout<<-1;return 0;}
for (int x=1;x<=m;x++)
if (calc(a[i],b[x])==1&&same(a[i],b[x])!=same(a[i],b[j])) {cout<<-1;return 0;}
}
cout<<0;
return 0;
//NOTICE LONG LONG!!!!!
}

  C:显然答案位置至少在一对飞船的交点上,这个数量级是O(nm)的。预处理每个位置能消灭哪些飞船,bitset存储,然后暴力枚举每一对位置,bitset上or一下count一下就完了。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<bitset>
using namespace std;
#define ll long long
#define N 122
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int n,m,a[N],b[N],ans;
bitset<N> f[N>>1][N>>1];
signed main()
{
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif
n=read(),m=read();
for (int i=1;i<=n;i++) a[i]=read();
for (int i=1;i<=m;i++) b[i]=read();
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
{
for (int x=1;x<=n;x++)
for (int y=1;y<=m;y++)
if (a[i]-a[x]==b[y]-b[j]) f[i][j][x]=1,f[i][j][y+n]=1;
}
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
for (int x=1;x<=n;x++)
for (int y=1;y<=m;y++)
ans=max(ans,(int)(f[i][j]|f[x][y]).count());
cout<<ans;
return 0;
//NOTICE LONG LONG!!!!!
}

  D:显然二分答案。相当于每将一个功率=x的任务放在第一批,就为功率<x的任务提供了一个垃圾桶。于是按功率从大到小排序,设f[i][j]为前i个任务剩余j个垃圾桶的最小值。唯一的问题是功率相同的任务间不能提供垃圾桶,状态再加一维处理即可。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 55
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int n;
ll f[N][N][N];
struct data
{
ll x,y;
bool operator <(const data&a) const
{
return x>a.x||x==a.x&&y<a.y;
}
}a[N];
bool check(ll k)
{
memset(f,42,sizeof(f));
f[0][0][0]=0;
for (int i=1;i<=n;i++)
{
int t=i;
while (t<n&&a[t+1].x==a[i].x) t++;
for (int j=i;j<=t;j++)
{
for (int x=0;x<=n;x++)
for (int y=0;y<=n;y++)
{
f[j][x][y]=f[j-1][x+1][y];
if (y) f[j][x][y]=min(f[j][x][y],f[j-1][x][y-1]+a[j].x-k*a[j].y);
}
}
i=t;
for (int j=n;j>=0;j--)
for (int x=0;x<=j;x++)
f[i][j][0]=min(f[i][j][0],f[i][j-x][x]);
}
for (int i=0;i<=n;i++) if (f[n][i][0]<=0) return 1;
return 0;
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif
n=read();
for (int i=1;i<=n;i++) a[i].x=1000ll*read();
for (int i=1;i<=n;i++) a[i].y=read();
sort(a+1,a+n+1);
ll l=0,r=10000000000000000ll,ans;
while (l<=r)
{
ll mid=l+r>>1;
if (check(mid)) ans=mid,r=mid-1;
else l=mid+1;
}
cout<<ans;
return 0;
//NOTICE LONG LONG!!!!!
}

  E:显然每个数有用的信息仅仅是其和x的大小,根据这个设为01后,即相当于求和为k的区间个数。又可以转换为前缀和之差为k的区间个数。裸的FFT。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 1100010
#define double long double
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int n,m,f[N],r[N];
ll ans[N];
const double PI=3.14159265358979324;
struct complex
{
double x,y;
complex operator +(const complex&a) const
{
return (complex){x+a.x,y+a.y};
}
complex operator -(const complex&a) const
{
return (complex){x-a.x,y-a.y};
}
complex operator *(const complex&a) const
{
return (complex){x*a.x-y*a.y,x*a.y+y*a.x};
}
}a[N],b[N];
void DFT(int n,complex *a,int p)
{
for (int i=0;i<n;i++) r[i]=(r[i>>1]>>1)|(i&1)*(n>>1);
for (int i=0;i<n;i++) if (i<r[i]) swap(a[i],a[r[i]]);
for (int i=2;i<=n;i<<=1)
{
complex wn=(complex){cos(2*PI/i),p*sin(2*PI/i)};
for (int j=0;j<n;j+=i)
{
complex w=(complex){1,0};
for (int k=j;k<j+(i>>1);k++,w=w*wn)
{
complex x=a[k],y=w*a[k+(i>>1)];
a[k]=x+y,a[k+(i>>1)]=x-y;
}
}
}
}
void mul(int n,complex *a,complex *b)
{
DFT(n,a,1),DFT(n,b,1);
for (int i=0;i<n;i++) a[i]=a[i]*b[i];
DFT(n,a,-1);
for (int i=0;i<n;i++) a[i].x=a[i].x/n;
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif
n=read(),m=read();
for (int i=1;i<=n;i++) f[i]=(read()<m);
for (int i=1;i<=n;i++) f[i]+=f[i-1];
for (int i=0;i<=n;i++) a[f[i]].x++,b[n-f[i]].x++;
int t=1;while (t<=(n<<1)) t<<=1;
mul(t,a,b);
for (int i=0;i<=n;i++) ans[i]=(ll)(a[i+n].x+0.5);
ans[0]-=n+1;ans[0]/=2;
for (int i=0;i<=n;i++) printf("%I64d ",ans[i]);
return 0;
//NOTICE LONG LONG!!!!!
}

  居然还有我能在场上做五题的div1

Codeforces Round #488 Div. 1的更多相关文章

  1. [Codeforces Round#488]Div.2

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

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

    [Codeforces]Round #488 (Div. 2) 总结 比较僵硬的一场,还是手速不够,但是作为正式成为竞赛生的第一场比赛还是比较圆满的,起码没有FST,A掉ABCD,总排82,怒涨rat ...

  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. 朱晔的互联网架构实践心得S1E10:数据的权衡和折腾【系列完】

    朱晔的互联网架构实践心得S1E10:数据的权衡和折腾[系列完] [下载本文PDF进行阅读] 本文站在数据的维度谈一下在架构设计中的一些方案对数据的权衡以及数据流转过程中的折腾这两个事情.最后进行系列文 ...

  2. form-data、x-www-form-urlencoded的区别

    form-data可以上传文件格式的,比如mp3.jpg这些:x-www-form-urlencoded不能选择格式文件,只能传key-value这种string格式的内容.

  3. 6 Prefer and Would rather

    1 prefer 使用 "prefer" 用来表明通常喜欢某件事甚于另一件事.说话者喜欢打高尔夫球更甚于喜欢打网球."prefer" 的后面可以接名词(&quo ...

  4. Chrome浏览器的版本查看 以及V8 javascript 引擎版本查看

    1. 发现chrome浏览器最新版本里面带的V8 引擎 版本号与chrome的版本号有一个关系, 这里简单总结一下: 在地址栏里面输入: chrome://version 即可显示出来 比如我正在使用 ...

  5. 设置SQLServer数据库内存

    需要设置SQLServer数据库的内存配置.登录数据库,这里使用的是SQLServer2008,右键点击最上方的服务器名,在弹出的菜单中,点击属性] 打开服务器属性窗口.默认显示的是第一项[常规]内容 ...

  6. 动态SQL3

    Oracle的批量操作 Oracle不支持VALUES(),(),()这种方式,所以不能用上一节所讲的方法. 有时候业务会包含很多次数据库操作,为了减少数据库连接,我们会选择一次提交大量sql, 这时 ...

  7. 关于golang.org/x包问题

    关于golang.org/x包问题 由于谷歌被墙,跟谷歌相关的模块无法通过go get来下载,解决方法: git clone https://github.com/golang/net.git $GO ...

  8. Redis五大数据类型

    首先说明下,Redis是:单线程+多路IO复用技术!!! string set  >  key  +  zset          list hash 常用的几个命令: >keys * 查 ...

  9. VMware与CentOS的安装与Linux简单指令

    一 . VMware与CentOS系统安装 下载CentOS系统的ISO镜像 # 官方网站,国外网站,下载速度会很慢 www.centos.org # 由于国外的下载速度慢,我们可以使用国内的镜像源 ...

  10. 老男孩python学习自修第五天【集合】

    特点: (1)无序 (2)不重复 使用场景: (1)关系测试 (2)去重 x & y 求交集 x | y 求并集 x - y 求差集 x ^ y 求对称差集 x.intersection(y) ...