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. C语言实现简单的停车场管理系统

    问题描述:停车场是一个能放n辆车的狭长通道,只有一个大门,汽车按到达的先后次序停放.若车场满了,车要停在门外的便道上等候,一旦有车走,则便道上第一辆车进入.当停车场中的车离开时,由于通道窄,在它后面呢 ...

  2. Intellij IDEA的Facets和Artifacts

    Facets: Facets表述了在Module中使用的各种各样的框架.技术和语言.这些Facets让Intellij IDEA知道怎么对待module内容,并保证与相应的框架和语言保持一致. 使用F ...

  3. 数据包分析中Drop和iDrop的区别

    数据包分析中Drop和iDrop的区别   在数据包分析中,Drop表示因为过滤丢弃的包.为了区分发送和接受环节的过滤丢弃,把Drop又分为iDrop和Drop.其中,iDrop表示接受环节丢弃的包, ...

  4. c#反射动态创建窗体

    根据窗体的名称动态创建窗体 Assembly assembly = Assembly.GetExecutingAssembly();             // 实例化窗体 try { Form f ...

  5. ToggleButton 和 Switch

           界面: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:a ...

  6. postgresql 臭氧8小时聚合函数

    1.定义数据拼接函数 CREATE OR REPLACE FUNCTION "public"."sfun"("results" _numer ...

  7. spring-data-redis数据类型

    一.引入依赖 <!-- 缓存 --> <dependency> <groupId>redis.clients</groupId> <artifac ...

  8. python编程中的一些有用插件或工具

    windows监控 在python编程的windows系统监控中,需要监控监控硬件信息需要两个模块:WMI 和 pypiwin32 . 前端文件上传插件 krajee karkit 后台管理模板 ni ...

  9. vs2010 出错:error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏(转)

    “LNK1123:转换到 COFF期间失败:文件无效或损坏”的解决方法 一.错误描述 之前写的程序隔段时间使用VS2010再次运行时出现如下错误: LINK fatal error LNK1123转换 ...

  10. AWS 数据库(七)

    数据库概念 关系型数据库 关系数据库提供了一个通用接口,使用户可以使用使用 编写的命令或查询从数据库读取和写入数据. 关系数据库由一个或多个表格组成,表格由与电子表格相似的列和行组成. 以行列形式存储 ...