1208 F

大意:  给定序列$a$, 求$\text{$a_i$|$a_j$&$a_k$}(i<j<k)$的最大值

枚举$i$, 从高位到低位贪心, 那么问题就转化为给定$x$, 求判断$[i+1,n]$内二进制包含$x$的个数是否不少于$2$, 可以对每个状态, 维护最远的两个位置即可.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc tr[o].l
#define rc tr[o].r
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head const int N = 3e6+10;
int n, a[N], vis[N], pre[N];
pii dp[N];
void add(int x, int p) {
if (dp[x].x&&dp[x].y) return;
if (dp[x].x==p||dp[x].y==p) return;
if (!dp[x].y) dp[x].y = p;
else dp[x].x = p;
REP(i,0,21) if (x>>i&1) add(x^1<<i,p);
}
int main() {
scanf("%d", &n);
REP(i,1,n) scanf("%d",a+i);
PER(i,1,n) add(a[i],i);
REP(i,1,n-2) vis[i] = 1;
int ans = 0;
PER(d,0,21) {
REP(i,1,n) if (vis[i]) {
if (a[i]>>d&1^1) {
pre[i] ^= 1<<d;
if (!dp[pre[i]].y||dp[pre[i]].x<=i) vis[i] = -1;
}
}
REP(i,1,n) if (vis[i]==1) ans |= 1<<d;
REP(i,1,n) if (vis[i]==-1) {
if (ans>>d&1) vis[i] = 0;
else vis[i] = 1, pre[i] ^= 1<<d;
}
}
printf("%d\n", ans);
}

1208 G

大意: 求$k$个不同边数的有相同外接圆正多边形, 使得顶点数最少.

显然所有多边形一定共用一个顶点$P$, 每个点就可以用它到$P$的距离来表示, 比如$k$边形表示为$0,\frac{1}{k},...,\frac{k-1}{k}$.

答案就为不同的分数个数, 那么考虑添加一个$k$边形, 它的贡献就是所有未出现过的因子的$\varphi$之和.

当$k$为$1$时直接取三角形即可, 其余情况把$\varphi$的前$n$项排序后取前$k+2$大即为答案, 这是因为对于一个$x$边形, 它的所有因子$y$满足$\varphi(y)\le \varphi(x),y<x$, 所以枚举到$x$时它的因子一定已经算过了.

1208 H

大意: 给定树, 每个点为蓝色或红色, 给定叶子颜色, 其余点记$b$为蓝儿子数, $r$为红儿子数, 若$b-r\ge k$为蓝色, 否则为红色. 要求实现三种操作: (1)求点$v$的颜色 (2)改变叶子$v$的颜色 (3)$k$的值改为$h$

Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) (1208F,1208G,1208H)的更多相关文章

  1. Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-D. Restore Permutation-构造+树状数组

    Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-D. Restore Permutation-构造+树状数组 [Pro ...

  2. Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-C. Magic Grid-构造

    Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-C. Magic Grid-构造 [Problem Descripti ...

  3. Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-E. Let Them Slide-思维+数据结构

    Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-E. Let Them Slide-思维+数据结构 [Problem ...

  4. Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) F. Bits And Pieces sosdp

    F. Bits And Pieces 题面 You are given an array

  5. Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) G. Polygons 数论

    G. Polygons Description You are given two integers

  6. RMQ+差分处理(Let Them Slide)Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)

    题意:https://codeforc.es/contest/1208/problem/E 现有n行w列的墙,每行有一排连续方块,一排方块可以左右连续滑动,且每个方块都有一个价值,第i 列的价值定义为 ...

  7. 线段树维护最后一个0的位置(Restore Permutation)Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)

    题意:https://codeforc.es/contest/1208/problem/D 给你长度为n的序列,s[i]的值为p[1]到p[i-1]中比p[i]小的数的和,让你求出p序列. 思路: 首 ...

  8. Codeforces Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)

    传送门 A. XORinacci 手玩三四项发现序列就是 $a,b,a\ xor\ b,a,b,...$,直接输出即可 #include<iostream> #include<cst ...

  9. Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)E(多重集维护)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;long long ans[1000007]; ...

随机推荐

  1. JEECG MiniDao优劣

    Minidao 1.5.1 - 我认为这是一个不严谨的错误 - andotorg的个人空间 - OSCHINAhttps://my.oschina.net/antsdot/blog/1800832 M ...

  2. MySQL 行转列 -》动态行转列 -》动态行转列带计算

    Pivot Table Using MySQL - A Complete Guide | WebDevZoomhttp://webdevzoom.com/pivot-table-using-mysql ...

  3. 算法习题---5-4交换学生(UVa10763)

    一:题目 有一组学生,他们手中分别有自己学校和想要去的目标学校(A,B).为了成功的交换学生,必须保证这一组学生中必须每两个人之间满足 s1 (A,B) 和 s2 (B,A).即两者原来和目标学校相对 ...

  4. 【Tomcat】Tomcat 配置开机启动

    参考:[Linux]开机自动启动脚本 环境:Linux环境(CentOS 7.4) 步骤 1.在/etc/rc.d/rc.local文件底部,添加内容: # apache-tomcat- /data/ ...

  5. 【linux】gitlab 的安装以及数据迁移

    一 .安装; 1  下载相应版本rpm包并安装 https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/ wget https://mirrors ...

  6. centos 安装最新版git

    对个人而言,gitlab有点浪费资源,占内存太大,一个博客服务器,配置比较低,用gitlab太浪费了.(公司使用gitlab,这个适合公司团队使用) 前提条件,放行git端口,防火墙添加放行规则,将3 ...

  7. Docker容器(二)——镜像制作

    制作Docker镜像有两种方式:第一种.docker commit,保存容器(Container)的当前状态到镜像后,然后生成对应的image:第二种.docker build,使用Dockerfil ...

  8. DEBUG技巧1 SE37将参数保存为测试数据

    1. SE37调试函数的时候,将参数保存为测试数据,供下次调试使用, 或者参考标准的赋值进行赋值 2. SE37 ->执行-> 测试序列 测试函数: CO_XT_COMPONENTS_DE ...

  9. 【linux学习笔记五】帮助命令

    man //查看ls作用 man ls man -f命令 相当于 whatis命令 --help ls --help help help shell help cd info详细命令帮助

  10. RobotFramework: 获取当前时间戳

    robot中先导入DateTime库 #获取当前时间:2019-07-31 10:46:29.940 ${time} Get Current Date result_format=timestamp ...