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. 深入浅出Tomcat系列

    原本打算一篇文章就发了的,无奈文章太长,阅读压力较大.为了让阅读体验更好一些,还是分多篇吧,大概6篇. 下面是这个主题的目录: 深入浅出Tomcat/1- 来历和配置文件 深入浅出Tomcat/2 - ...

  2. 深入理解Redis Cluster

    Redis Cluster采用虚拟槽分区,所有的key根据哈希函数映射到0~16383槽内,计算公式: slot = CRC16(key) & 16383 每个节点负责维护一部分槽以及槽所映射 ...

  3. 一起学习造轮子(三):从零开始写一个React-Redux

    本文是一起学习造轮子系列的第三篇,本篇我们将从零开始写一个React-Redux,本系列文章将会选取一些前端比较经典的轮子进行源码分析,并且从零开始逐步实现,本系列将会学习Promises/A+,Re ...

  4. 小程序解决方案 Westore - 组件、纯组件、插件开发

    数据流转 先上一张图看清 Westore 怎么解决小程序数据难以管理和维护的问题: 非纯组件的话,可以直接省去 triggerEvent 的过程,直接修改 store.data 并且 update,形 ...

  5. Bootstrap 栅格 样式 组件 插件

    -----------------------------起先是我们造成习惯,后来是习惯造成我们. day 51 Bootstrap  官方网站:   bootcss.com/ <!DOCTYP ...

  6. 使用Request+正则抓取猫眼电影(常见问题)

    目前使用Request+正则表达式,爬取猫眼电影top100的例子很多,就不再具体阐述过程! 完整代码github:https://github.com/connordb/Top-100 总结一下,容 ...

  7. 【问题解决方案】之 cmd 窗口问题汇总

    cmd窗口C盘切不到其他盘的解决方案: 1.切换盘符,直接键入其他盘,如:>>D: (回车) 2.强行切换>>cd /d D: 或者 >>pushd C:

  8. #Leetcode# 524. Longest Word in Dictionary through Deleting

    https://leetcode.com/problems/longest-word-in-dictionary-through-deleting/ Given a string and a stri ...

  9. hdu1421_搬寝室

    题目:搬寝室 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1421 #include<stdio.h> #include<algor ...

  10. Dart语法基础

    hello world // Define a function. printNumber(num aNumber) { print('The number is $aNumber.'); // Pr ...