A

直接判存不存在连续的三个包含A,B,C就行

/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
const int mod = 1e9 + , gakki = + + + + 1e9;
const int MAXN = 1e5 + , MAXM = 1e5 + , N = 2e5 + ;
const int MAXQ = ;
int sum[];
char f[];
int main()
{
ios_base::sync_with_stdio();
cin.tie(); string a;
cin >> a;
int len=a.size();
for (int i = ; i < a.size(); i++)
{
int l = max(i - , );
int r = min(len - , i + );
if (a[i] == 'A')
{
for (int j = l; j <= r; j++)
{
sum[j] += ;
}
}
else if (a[i] == 'B')
{
for (int j = l; j <= r; j++)
{
sum[j] += ;
}
}
else if (a[i] == 'C')
{
for (int j = l; j <= r; j++)
{
sum[j] += ;
}
}
}
for (int i = ; i < a.size(); i++)
{
if (sum[i] == )
{
cout << "Yes" << endl;
return ;
}
}
cout << "No" << endl;
return ;
}

B

下列情况有答案

1.f[i]!=f[i-p]

2.f[i]=f[i-p]='.'

3.f[i]!='.'&&f[i-p]='.'或者f[i]='.'&&f[i-p]!='.'

不是这几种情况直接输出NO即可 是的话 先构造出一处然后剩下的随便赋值了

/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
const int mod = 1e9 + , gakki = + + + + 1e9;
const int MAXN = 1e5 + , MAXM = 1e5 + , N = 2e5 + ;
const int MAXQ = ;
int sum[];
char f[];
int main()
{
ios_base::sync_with_stdio();
cin.tie(); int flag = ;
int n, p;
scanf("%d %d", &n, &p);
scanf("%s", f + );
for (int i = p + ; i <= n; i++)
{
if (f[i] == '.')
{
if (f[i - p] != '.')
{
if (f[i - p] == '')
{
f[i] = '';
}
else
{
f[i] = '';
}
flag = ;
}
else
{
f[i] = '';
f[i - p] = '';
flag = ;
}
}
else
{
if (f[i - p] == '.')
{
if (f[i] == '')
{
f[i - p] = '';
}
else
{
f[i - p] = '';
}
flag = ;
}
else
{
if (f[i] != f[i - p])
{
flag = ;
}
}
}
}
for (int i = ; i <= n; i++)
{
if (f[i] == '.')
{
f[i] = '';
}
}
if (!flag)
{
cout << "No" << endl;
}
else
{
printf("%s\n", f + );
}
}

C

构造题

直接搞个48*50的大块 分成4个12*50的小块

再满足条件地在大块里面扣一个个1*1的小块即可

/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
const int mod = 1e9 + , gakki = + + + + 1e9;
const int MAXN = 1e5 + , MAXM = 1e5 + , N = 2e5 + ;
const int MAXQ = ;
int sum[];
char f[][];
int main()
{
ios_base::sync_with_stdio();
cin.tie(); int a, b, c, d;
cin >> a >> b >> c >> d;
cout << << " " << << endl;
for (int i = ; i <= ; i++)
{
for (int j = ; j <= ; j++)
{
if (i <= )
{
f[i][j] = 'A';
}
else if (i <= )
{
f[i][j] = 'B';
}
else if (i <= )
{
f[i][j] = 'C';
}
else
{
f[i][j] = 'D';
}
}
}
a--, b--, c--, d--;
int dx = , dy = ;
for (int i = ; i <= a; i++)
{
if (dy > )
{
dy -= , dx += ;
}
f[dx][dy] = 'A';
dy+=;
}
dx=,dy=;
for (int i = ; i <= b; i++)
{
if (dy > )
{
dy -= , dx += ;
}
f[dx][dy] = 'B';
dy+=;
}
dx=,dy=;
for (int i = ; i <= c; i++)
{
if (dy > )
{
dy -= , dx += ;
}
f[dx][dy] = 'C';
dy+=;
}
dx=,dy=;
for (int i = ; i <= d; i++)
{
if (dy > )
{
dy -= , dx += ;
}
f[dx][dy] = 'D';
dy+=;
}
for(int i=;i<=;i++)
{
for(int j=;j<=;j++)
{
cout<<f[i][j];
}
cout<<endl;
}
}

D

题意:

给你n块云(1<=n<=1e5) 每块云的长度是确定的L 月亮在原点 每块云覆盖的区间为[Xi,Xi+L](-1e8<=Xi<=1e8) 初始每块云的速度是1或者-1

现在给你一个Wmax 你可以选择一个速度W(-Wmax<=W<=Wmax)使得有一对云在某一个时间同时覆盖住月亮

问你可以由多少对

解:

http://codeforces.com/blog/entry/59968

把X轴上再加一条Y轴表示时间 这样某一块云运动的轨迹就变成了一个斜着的条

如果两个云有交集的话 在图上就变成有一个公共的小蓝方块

接着我们把W的速度转给月亮 而不是给云 这样云的速度就不变 方便思考和计算

如果一对云可以同时遮到月亮的话 小蓝方块与黄色月亮运动范围是有交集的 即小蓝方块的最高点Y坐标大于下界斜率*当前横坐标

因为1<=W<=Wmax 所以月亮下界的斜率最小为1/Wmax 假设有一个往左的云u 有一个往右的云v 可以算出他们的小蓝块的最高点坐标为((Xu+Xv+L)/2,(Xu-Xv+L)/2)

接下来的要求即是解不等式  把Xu+Xv+L分>=0与<0两种情况讨论即可

/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
const int mod = 1e9 + , gakki = + + + + 1e9;
const int MAXN = 1e5 + , MAXM = 1e5 + , N = 2e5 + ;
const int MAXQ = ;
int n, l, w;
int x[MAXN], v[MAXN];
vector<int> pos, neg;
inline int div_floor(ll a, int b)
{
if (b == )
{
if (a > )
{
return INT_MAX;
}
else
{
return INT_MAX * -;
}
}
if (a % b < )
{
a -= (b + a % b);
}
return a / b;
}
int main()
{
scanf("%d %d %d", &n, &l, &w);
for (int i = ; i < n; i++)
{
scanf("%d %d", &x[i], &v[i]);
if (v[i] == )
{
pos.push_back(x[i]);
}
else
{
neg.push_back(x[i]);
}
}
sort(pos.begin(), pos.end()), sort(neg.begin(), neg.end());
ll anser = ;
for (int v : neg)
{
auto barrier = lower_bound(pos.begin(), pos.end(), -v - l);
int ansmax0 = div_floor(1LL * (v + l) * (w + ) - , w - );
int ansmax1 = div_floor(1LL * (v + l) * (w - ) - , w + );
anser += (upper_bound(pos.begin(), barrier, ansmax0) - pos.begin()) + (upper_bound(barrier, pos.end(), min(v, ansmax1)) - barrier);
}
printf("%lld\n", anser);
}

E

待补

Codeforces 989 P循环节01构造 ABCD连通块构造 思维对云遮月参考系坐标轴转换的更多相关文章

  1. P1141 01迷宫 dfs连通块

    题目描述 有一个仅由数字000与111组成的n×nn \times nn×n格迷宫.若你位于一格0上,那么你可以移动到相邻444格中的某一格111上,同样若你位于一格1上,那么你可以移动到相邻444格 ...

  2. P1141 01迷宫(连通块模板)

    题目描述 有一个仅由数字0与1组成的n×n格迷宫.若你位于一格0上,那么你可以移动到相邻4格中的某一格1上,同样若你位于一格1上,那么你可以移动到相邻4格中的某一格0上. 你的任务是:对于给定的迷宫, ...

  3. Codeforces Round #222 (Div. 1) Maze —— dfs(连通块)

    题目链接:http://codeforces.com/problemset/problem/377/A 题解: 有tot个空格(输入时统计),把其中k个空格变为wall,问怎么变才能使得剩下的空格依然 ...

  4. Codeforces 920E-Connected Components? (set,补图,连通块)

    Connected Components? CodeForces - 920E You are given an undirected graph consisting of n vertices a ...

  5. Codeforces 982 树边两端点计数偶数连通块 鲨鱼活动最小K最大location 扩展欧几里得方块内光线反射

    A /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define pb push_bac ...

  6. Codeforces Round #117 (Div. 2) D.Common Divisors(KMP最小循环节)

    http://codeforces.com/problemset/problem/182/D 题意:如果把字符串a重复m次可以得到字符串b,那么我们称字符串a为字符串b的一个因子,现在给定两个字符串S ...

  7. codeforces 825F F. String Compression dp+kmp找字符串的最小循环节

    /** 题目:F. String Compression 链接:http://codeforces.com/problemset/problem/825/F 题意:压缩字符串后求最小长度. 思路: d ...

  8. Common Divisors CodeForces - 182D || kmp最小循环节

    Common Divisors CodeForces - 182D 思路:用kmp求next数组的方法求出两个字符串的最小循环节长度(http://blog.csdn.net/acraz/articl ...

  9. Codeforces Round #383 (Div. 2) A,B,C,D 循环节,标记,暴力,并查集+分组背包

    A. Arpa’s hard exam and Mehrdad’s naive cheat time limit per test 1 second memory limit per test 256 ...

随机推荐

  1. Android内存Activity泄露:Handler与Threads

    Java使用有向图机制,通过GC自动检查内存中的对象(什么时候检查由虚拟机决定),如果GC发现一个或一组对象为不可到达状态,则将该对象从内存中回收.也就是说,一个对象不被任何引用所指向,则该对象会在被 ...

  2. cors 预请求

    1.CORS的其他限制 默认允许的方法只有:GET.HEAD.POST默认允许的Content-Type:text/plain.multipart/form-data.applicaton/x-www ...

  3. flask包request搭建微服务(模拟测试桩)

    from flask import Flask,requestimport json app=Flask(__name__)@app.route('/outsideWeb/integration/qr ...

  4. OpenStack 制作image,启动VM,无console log

    OpenStack image 制作官方文档:https://docs.openstack.org/image-guide/create-images-manually.html 如果通过制作的镜像启 ...

  5. Linux 常用命令之 mv cp scp

    1.mv 命令是move的缩写,用于文件(或文件夹)移动的. 1)将 luna 目录下的文件 a.txt,移动到 miracle 目录下: mv ./luna/a.txt ./miracle/ 2)将 ...

  6. flutter详解路由栈(二)

    前面,我们已经知道如何简单在路由栈中 push.pop 实例,然而,当遇到一些特殊的情况,这显然不能满足需求.学习 Android 的同学知道 Activity 的各种启动模式可以完成相应需求,Flu ...

  7. java:LeakFilling(Servlet,JSP)

    1.web-inf中的  .jsp 文件不会运行,其他都根据web.xml文档中的自然顺序进行运行 2.keep-alive 长连接(持续)  UDP,TCP短连接 3.状态码:1(消息异常) 2(成 ...

  8. 第 10 章 python进程与多进程

    一.背景知识 顾明思义,进程即正在执行的一个过程,进程是对正在云的程序的一个抽象. 进程的概念起源与操作系统,是操作系统最核心的概念,也是操作系统提供的最古老也是最重要的抽象概念之一,操作系统的其他所 ...

  9. poatman接口测试--初试

    接到测试任务,对两个商品接口,进行接口测试 测试工具:postman 域名:rap2查找的或询问开发, 接口的参数规则:参考rap2的备注 开发没有添加详细说明的,让开发补充说明规则,及定义的返回状态 ...

  10. LeetCode.961-2N数组中N次重复的元素(N-Repeated Element in Size 2N Array)

    这是悦乐书的第365次更新,第393篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第227题(顺位题号是961).在大小为2N的数组A中,存在N+1个唯一元素,并且这些元 ...