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. Sqlmap全参数详解

    sqlmap全参数详解 sqlmap是在sql注入中非常常用的一款工具,由于其开源性,适合从个人到企业,从学习到实战,各领域各阶段的应用,我们还可以将它改造成我们自己独有的渗透利器.这款工具中,大大小 ...

  2. org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

    编程中遇到:org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot ...

  3. 关于Android8.0 静态注册广播 行为变更的说明。

    Andorid 8.0 对广播的使用做了变更. 当广播接收器使用静态注册方式使用时,除了一些例外,这个接收器接收不到隐式广播. 注意这个“隐式”是重点. 看了网上几篇文章,对这个变更理解有误.错误的理 ...

  4. GIS自定义地理处理工具--极值提取

    GIS自定义地理处理工具--极值提取 关键词:最大值提取,最小值提取,极值提取,极小值提取,极大值提取 商务合作,科技咨询,版权转让:向日葵,135—4855__4328,xiexiaokui#qq. ...

  5. EditText限制输入的几种方式及只显示中文汉字的做法

    最近项目要求限制密码输入的字符类型, 例如不能输入中文.   现在总结一下EditText的各种实现方式,  以比较各种方法的优劣. 第一种方式:  设置EditText的inputType属性,可以 ...

  6. 123457123456#0#-----com.cym.shuXue02--前拼后广--开心学数学

    com.cym.shuXue02--前拼后广--开心学数学

  7. DEBUG技巧里的问题1 双击某个变量不能显示

    DEBUG模式  双击 ls_return-type 变量不能显示,提示警告消息 好像说明的不是这个问题, 把字段复制到右边的变量框里可以显示 这个确实有点奇怪了

  8. Nginx - upstream sent invalid chunked response while reading upstream 异常问题

    一个 post 的请求,直接调接口服务数据正常返回,但是通过 nginx 代理后, 什么都没有返回. nginx 配置如下: 使用 postman 调用,返回如下: 于是检查日志报错信息,如下: ng ...

  9. 单机prometheus vs 集群kube-prometheus+prometheus-operator

    prometheus 组件: node-exporter:9100端口 https://segmentfault.com/a/1190000017959127

  10. MySQL 8中使用全文检索示例

    首先建议张册测试用的表test,并使用fulltext说明将title和body两列的数据加入全文检索的索引列中: drop table if exists test; create table te ...