A

构造题

有一个44的方格 每次放入一个横向12或竖向2*1的方格

满了一行或一列就会消掉

求方案

不放最后一行 这样竖行就不会消

然后竖着的放前两行 横着的放第三行 循环放就可以啦

#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
const int N = 1e3 + 5;
using namespace std;
const int r[2][2] = {{3, 1}, {3, 3}};
const int c[4][2] = {{1, 1}, {1, 2}, {1, 3}, {1, 4}};
char str[N];
int main(){
scanf("%s", str + 1);
int len = strlen(str + 1);
int cntr = 0, cntc = 0;
for(int i = 1; i <= len; ++i){
if(str[i] == '1'){
printf("%d %d\n", r[cntr][0], r[cntr][1]);
++cntr; if(cntr >= 2) cntr -= 2;
}
else {
printf("%d %d\n", c[cntc][0], c[cntc][1]);
++cntc; if(cntc >= 4) cntc -= 4;
}
}
return 0;
}

B

这是一道交互题

有一个数a 现在你每次可以询问"? x y"

如果\(x \mod a >= y \mod a\) 那么返回"x" 否则返回"y"

如果得出结果 就输出"! a" a是猜到的值

多数据 每轮以start开头 end表示结束

每轮询问不能超过60次

\(a \leq 1e9\)

首先考虑特判1

用"? 0 1"就可以 (x表示是1)

现在已经知道不是1了 就用"? 1 2"来判

显然如果a == 2那么返回x

如果a >= 3那么返回y

依此类推 倍增就好啦 注意每次询问是左开右闭的

扩大到\(x \le a \leq y\)时 用同样的方法每次收拢\(frac{y - x}{2}\)个就好啦

直到y - x == 1此时y就是答案

1e9 < 2 ^ 30

再加上第一次特判 显然可过

C

给你一张没有重边自环的n个点m条边的无向图 还有一个常数k

保证每个点度数至少为3

要求完成下列任务之一即可 如果都无解输出-1

任务一:找到一条长度至少为\(\lfloor frac{n}{k} \rfloor\)的路径

任务二:找到k个环 每个环要求满足:

  • 1 长度至少为3
  • 2 长度不是3的倍数
  • 3 这个环里必须至少有一个点满足它只属于这个环 不属于其他环

    \(n, k \leq 2.5 * 10^5 m \leq 5 * 10^5\)

    HINT 标签:constructive algorithms, dfs and similar

首先任务一很好办啊 bfs一下纪录father就可以了

如果没有的话 任务二中显然如果有两个环有公共边 那么这两个环上的点都不能做representative - vertex

先把这张图tarjan一波

对于一个双连通分量 如果其中不是割点的点度数有大于2的 那么说明有多环

所以我们在找到一个强连通分量的时候

如果这个bc里面(所有点都是割点并且这些割点都不是单独的) 或者有不是割点的点度数大于2 那么弃掉它

否则这整个就是一个环(或者单点) 判断它是不是\(size \geq 3\)

如果是就可以输出

orz

#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#include <vector>
const int N = 5e5 + 5;
using namespace std;
struct Edge{
int v, next;
}edge[N << 1];
int head[N], esize;
inline void addedge(int x, int y){
edge[++esize] = (Edge){y, head[x]}; head[x] = esize;
}
int n, m, k;
int dfn[N], tim, dis[N], fa[N], mx;
vector<int> cyc, leaf, son;
bool vis[N];
void dfs(int x, int ff){
dfn[x] = ++tim, dis[x] = dis[ff] + 1, fa[x] = ff;
if(dis[mx] < dis[x]) mx = x;
vis[x] = 1;
bool lf = 1;
for(int i = head[x], vv; ~i; i = edge[i].next){
vv = edge[i].v; if(vis[vv]) continue;
dfs(vv, x);
lf = 0;
}
if(lf) leaf.push_back(x);
} int main(){
memset(head, -1, sizeof(head));
scanf("%d%d%d", &n, &m, &k);
for(int i = 1, x, y; i <= m; ++i){
scanf("%d%d", &x, &y);
addedge(x, y), addedge(y, x);
}
dfs(1, 0);
if(dis[mx] > (n / k)){
printf("PATH\n%d\n", dis[mx]);
while(mx)
printf("%d ", mx), mx = fa[mx];
}
else {
printf("CYCLES\n");
int cnt = 0;
for(auto i : leaf){
son.clear(); cyc.clear();
for(int j = head[i]; ~j; j = edge[j].next) if(edge[j].v != fa[i]) son.push_back(edge[j].v); if((dis[i] - dis[son[0]]) % 3 != 2){
//printf("%d %d\n", dis[i], dis[son[0]]);
int j = i;
while(j != son[0]) cyc.push_back(j), j = fa[j];
cyc.push_back(j);
}
else if((dis[i] - dis[son[1]]) % 3 != 2){
int j = i;
while(j != son[1]) cyc.push_back(j), j = fa[j];
cyc.push_back(j);
}
else {
//printf("*");
if(dis[son[0]] < dis[son[1]]) swap(son[0], son[1]);
cyc.push_back(i);
int j = son[0];
while(j != son[1]) cyc.push_back(j), j = fa[j];
cyc.push_back(j);
}
printf("%d\n", cyc.size());
for(auto j : cyc) printf("%d ", j);
printf("\n");
if(++cnt == k) break;
}
}
return 0;
}

D

这道题如果所有数的最大公约数为一

那当然不用管了 输出零就好

\(2 * 3 * 5 * 7 * 11 * ... * 31 = 200560490130 \ge 10^12\)

这样的话最多gcd有11种质因数

那么对于一种质因数 要消掉它的话 就要把任一个数消掉这种这种质因数

所以这么说最多只需要消掉11个数

只有十一个? 考虑状压dp

f[i][S] = 最小的被消掉的数的权值之和 之所以有i那一位是为了统计用了多少个数 就像背包一样

有可能一个数被消掉的不只是一个质因数 那怎么办?

这个时候我们先处理出这个数中(gcd包含的那些质因数)的幂的乘积

也可以把它塞进一个map 这样是为了不重复处理一个数的质因数集合

Codeforces Round #534 (Div. 1)的更多相关文章

  1. Codeforces Round #534 (Div. 2) D. Game with modulo(取余性质+二分)

    D. Game with modulo 题目链接:https://codeforces.com/contest/1104/problem/D 题意: 这题是一个交互题,首先一开始会有一个数a,你最终的 ...

  2. CF1103D Codeforces Round #534 (Div. 1) Professional layer 状压 DP

    题目传送门 https://codeforces.com/contest/1103/problem/D 题解 失去信仰的低水平选手的看题解的心路历程. 一开始看题目以为是选出一些数,每个数可以除掉一个 ...

  3. CF1103C Johnny Solving (Codeforces Round #534 (Div. 1)) 思维+构造

    题目传送门 https://codeforces.com/contest/1103/problem/C 题解 这个题还算一个有难度的不错的题目吧. 题目给出了两种回答方式: 找出一条长度 \(\geq ...

  4. Codeforces Round #534 (Div. 2)D. Game with modulo-1104-D(交互+二分+构造)

    D. Game with modulo time limit per test 1 second memory limit per test 256 megabytes input standard ...

  5. Codeforces Round #534 (Div. 2)

    B. Game with string 题意: 给出一个字符串s只包括小写字母.当轮到一个玩家的时候,他可以选择两个连续且相等的字母并且删除它.当一个玩家没得删的时候他就输了. 题解: 乍一看有点懵, ...

  6. Codeforces Round #534 (Div. 2) Solution

    A. Splitting into digits Solved. #include <bits/stdc++.h> using namespace std; int n; void sol ...

  7. [ACM]Codeforces Round #534 (Div. 2)

    A. Splitting into digits Vasya has his favourite number n. He wants to split it to some non-zero dig ...

  8. Codeforces 1104 D. Game with modulo-交互题-二分-woshizhizhang(Codeforces Round #534 (Div. 2))

    D. Game with modulo time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. Codeforces Round #534 (Div. 2) D. Game with modulo 交互题

    先二分一个区间,再在区间里面二分即可: 可以仔细想想,想明白很有意思的: #include<iostream> #include<cstdio> #include<alg ...

随机推荐

  1. 网页三剑客:HTML+CSS+JavaScript 之JavaScript

    JavaScript 简介 JavaScript 是互联网上最流行的脚本语言,这门语言可用于 HTML 和 web,更可广泛用于服务器.PC.笔记本电脑.平板电脑和智能手机等设备. JavaScrip ...

  2. Linux硬盘文件分析取证(SSH过的IP)

    在线靶场: https://www.mozhe.cn 背景介绍 某运维人员发现服务器最近被一个IP连接过SSH,请找到连接服务器SSH的IP. 实训目标 1.了解Linux备份方式: 2.了解Acce ...

  3. Android studio怎么使用自定义的framework而避免冲突报错和点不进去报红。

    文件:xx\project_abc\video\build.gradle保证可以运行到自定义的framework而不报错,可能因为project和module名字相同所以导致下面的路径是绝对路径,其他 ...

  4. Android Interpolator解析

    本文部分图片转自:https://blog.csdn.net/lgaojiantong/article/details/39451243 目录 自定义插值器 系统插值器 1. 自定义插值器 要自定义插 ...

  5. ElasticSearch head 插件安装

    head 客户端可以很方便在上面创建索引,类型,文档,还有查询,使用它管理elasticsearch 提高效率. 在安装head 客户端之前必须安装node.js 环境,因为它是用node.js 编写 ...

  6. Parcelable 小记

    Parcelable 类,接口类,用于数据的序列化封装.常见的Bundle,Intent类都实现了该类.   实现该类需要实现writeToParcel和describeContents方法,最后还需 ...

  7. PL/SQL连接数据库时报错12154

    研究了半天,最终我发现和环境变量没有半毛钱关系,就是tsnnames这个文件的格式错了.

  8. vue 导出xlsx表功能

    详细步骤: 1.需要安装三个依赖: npm install -S file-saver xlsx npm install -D script-loader 两个命令行包含三个依赖. 2.项目中src下 ...

  9. k8s 集群部署问题整理

    1.hostname “master” could not be reached在host中没有加解析 2.curl -sSL http://localhost:10248/healthzcurl: ...

  10. KL散度、JS散度、Wasserstein距离

    1. KL散度 KL散度又称为相对熵,信息散度,信息增益.KL散度是是两个概率分布 $P$ 和 $Q$  之间差别的非对称性的度量. KL散度是用来 度量使用基于 $Q$ 的编码来编码来自 $P$ 的 ...