D:首先考虑如果给定白棋位置,如何判断胜负。黑棋获胜需要四个方向都有能贴上白棋的棋子。由于每一轮都必须移动,显然先对平面黑白染色一下,只有与白棋所在格异色的黑棋才需要考虑。考虑让一个黑棋去贴上白棋某个方向,那么能贴上的条件是该方向坐标之差>另一方向坐标之差。因为如果其往这边逃的话,这样才有足够的时间冲过去拦住。若往其他方向逃,只要模仿其动作即可,处于逃跑方向的棋子会对其作出制裁。

  可以发现每个黑棋对每个位置的白棋都只有一种能将其锁死的方向,四个方向的分界线形成一个X形。于是现在要数的是被任意四个黑棋的不同方向包含的白棋数量。

  斜着的东西很难考虑,把坐标系旋转一下45°,分界线就变成了一个十字形,就看起来非常舒服了。这样的话扫描线扫过去,维护线两边的黑棋纵坐标上下界,两边上界取min下界取max即可得到该直线上的被锁死的白棋纵坐标上下界。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 100010
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,u,v,mx[N],mn[N];
ll ans;
struct data
{
int x,y;
bool operator <(const data&a) const
{
return x<a.x;
}
}a[N],b[N];
void solve(data *a,int n)
{
for (int i=1;i<=n;i++)
{
int x=a[i].x,y=a[i].y;
a[i].x=y-x,a[i].y=x+y;
}
sort(a+1,a+n+1);
//for (int i=1;i<=n;i++) cout<<a[i].x<<' '<<a[i].y<<endl;
mx[n+1]=-N,mn[n+1]=N;
for (int i=n;i>=1;i--) mx[i]=max(mx[i+1],a[i].y),mn[i]=min(mn[i+1],a[i].y);
int MX=-N,MN=N;
int cur=0;
for (int i=a[1].x;i<=a[n].x;i++)
{
while (cur<n&&i==a[cur+1].x) cur++,MX=max(MX,a[cur].y),MN=min(MN,a[cur].y);
ans+=max(min(MX,mx[cur+1])-max(MN,mn[cur+1]),0);
}
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("d.in","r",stdin);
freopen("d.out","w",stdout);
#endif
n=read();
for (int i=1;i<=n;i++)
{
int x=read(),y=read();
if ((x+y)%2) a[++u].x=x,a[u].y=y;
else b[++v].x=x,b[v].y=y;
}
solve(a,u);solve(b,v);
cout<<ans/4;
return 0;
//NOTICE LONG LONG!!!!!
}

  E:将每个限制存储在其右端点上,记录最靠右的li,0、li,1表示li,j到i至少要有一个j。设f[i][0/1]为第i位是0/1且满足所有右端点在i及i之前的限制的序列数量。转移考虑枚举最后一段连续0/1有多长,不妨考虑0,即有f[i][0]=Σf[j][1] (j>=max{lj~i,1})。前缀和一下,二分一下转移的最远点(直接移动指针难以更新max{l}),即可做到O(klogk)。

  注意到当一个点不存在限制时,f[i][0]=f[i][1]=f[i-1][0]+f[i-1][1]。如果连续一段没有限制,dp值会构成公比2的等比数列。于是考虑离散化后dp。然后应该和上面的dp没有什么太大的区别。

  可是为什么想想就很难写啊。咕咕咕。有缘再补(?)

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

  1. Codeforces Round #468 Div. 2题解

    A. Friends Meeting time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  2. Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)B. World Cup

    The last stage of Football World Cup is played using the play-off system. There are n teams left in ...

  3. Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)

    A.B都是暴力搞一搞. A: #include<bits/stdc++.h> #define fi first #define se second #define mk make_pair ...

  4. codeforces 930b//Game with String// Codeforces Round #468 (Div. 1)

    题意:一个串,右循环移位后,告诉你第一个字母,还能告诉你一个,问你能确定移位后的串的概率. 用map记录每个字母出现的位置.对于每个字母,用arr[j][k]记录它的所有出现位置的后j位是字母k的个数 ...

  5. Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)D. Peculiar apple-tree

    In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity ...

  6. Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)C. Laboratory Work

    Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some v ...

  7. Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)A. Friends Meeting

    Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the ...

  8. Codeforces Round #468 (Div. 2 )D. Peculiar apple-tree_BFS

    题目简单,不多解释. Code: #include<cstdio> #include<queue> using namespace std; const int maxn = ...

  9. 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 ...

随机推荐

  1. 几种事务的隔离级别,InnoDB如何实现?

    事务ACID特性,其中I代表隔离性(Isolation). 什么是事务的隔离性? 隔离性是指,多个用户的并发事务访问同一个数据库时,一个用户的事务不应该被其他用户的事务干扰,多个并发事务之间要相互隔离 ...

  2. nginx 动态添加ssl模块

    一.查看nginx模块 /usr/local/nginx/sbin/nginx -V 二.安装openssl包 yum -y install pcre  pcre-devel zlib  zlib-d ...

  3. 剑指Offer-- 翻转链表 (python版)

    输入一个链表,反转链表后,输出链表的所有元素. # -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val ...

  4. 微信小程序学习笔记以及VUE比较

    之前只是注册了一下微信小程序AppID,随便玩了玩HelloWorld!(项目起手式),但是最近看微信小程序/小游戏,崛起之势不可阻挡.小程序我来了!(果然,一入前端深似海啊啊啊啊啊~) 编辑器: S ...

  5. 01-JavaScript介绍

    JavaScript价绍 1.引言 Web前端有三层: HTML:从语义的角度,描述页面结构 CSS:从审美的角度,描述样式(美化页面) JavaScript:从交互的角度,描述行为(提升用户体验) ...

  6. sqlserver2008 传入的表格格式数据流(tds)协议流不正确。

    起因是在sql 2008 里使用 sql prompt 报了一个内部连接致命错误,原本应该想到是数据库连接问题的,奇怪的是能连接上数据库也能查询表仅仅是用不了工具没有智能提示. 几经查询无果,度娘上之 ...

  7. debian下 Hadoop 1.0.4 集群配置及运行WordCount

    说明:我用的是压缩包安装,不是安装包 官网安装说明:http://hadoop.apache.org/docs/r1.1.2/cluster_setup.html,繁冗,看的眼花...大部分人应该都不 ...

  8. Zk搭建(Zookeeper)

      第一步: 上传----解压   tar -zxvf zookeeper-3.4.5.tar.gz----                配置zk的环境变量  ----------配置源码 vim ...

  9. 封装day.js

    封装day.js import dayjs from 'dayjs' import 'dayjs/locale/zh-cn' import relativeTime from 'dayjs/plugi ...

  10. How To: Capture Android & iOS Traffic with Fiddler

    How To: Capture iOS Traffic with Fiddlerhttps://www.telerik.com/blogs/how-to-capture-ios-traffic-wit ...