A:签到。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int b,k,a[100010];
signed main()
{
/*#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
const char LL[]="%I64d\n";
#endif*/
b=read(),k=read();b&=1;
for (int i=1;i<=k;i++) a[i]=read();
if (b==0)
{
if (a[k]&1) cout<<"odd";
else cout<<"even";
}
else
{
int s=0;
for (int i=1;i<=k;i++) s+=a[i];
if (s&1) cout<<"odd";
else cout<<"even";
}
return 0;
//NOTICE LONG LONG!!!!!
}

  B:显然先连接距离较小的点。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 100010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int n,m,k,a[N],b[N],ans;
signed main()
{
/*#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
const char LL[]="%I64d\n";
#endif*/
n=read(),m=read(),k=read();
for (int i=1;i<=n;i++) a[i]=read();
ans=a[n]-a[1]+1;
for (int i=2;i<=n;i++) b[i]=a[i]-a[i-1];
sort(b+2,b+n+1);reverse(b+2,b+n+1);
for (int i=2;i<=k;i++) ans-=b[i]-1;
cout<<ans;
return 0;
//NOTICE LONG LONG!!!!!
}

  C:当a!=2k-1时,令k为满足2k-1>a的最小正整数,显然可以令b=2k-1^a使答案成为2k-1,并且显然不可能更优。a=2k-1时直接暴力打表。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 100010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int q,ans[1<<25];
signed main()
{
/*#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
const char LL[]="%I64d\n";
#endif*/
q=read();
for (int i=1;i<=22;i++)
{
for (int j=1;j<(1<<i)-1;j++)
ans[(1<<i)-1]=max(ans[(1<<i)-1],gcd((1<<i)-1&j,(1<<i)-1^j));
}
ans[(1<<23)-1]=178481;
ans[(1<<24)-1]=5592405;
ans[(1<<25)-1]=1082401;
while (q--)
{
int x=read();
if (ans[x]>0) printf("%d\n",ans[x]);
else
{
while (x!=(x&-x)) x^=x&-x;
printf("%d\n",(x<<1)-1);
}
}
return 0;
//NOTICE LONG LONG!!!!!
}

  E:https://www.cnblogs.com/Gloid/p/10060025.html 作为一个做过所谓原题的选手看了1h这个题感到十分自闭。事实上第一眼就想到了这个原题,发现并不一样之后就去梦游了。毕竟当时也不是用前缀和的做法做的,而是自己想了半天搞了个做法还觉得挺nb,反应不过来也挺正常。但现在感觉我这做法好像也能类似的搬过来?自闭了啊?

  比较差分集合是否相同即可,因为每次操作相当于交换差分数组中相邻两数。注意特判首尾。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 100010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int n,q[N<<4],head,tail,cnt;
ll a[N],b[N];
bool flag[N];
signed main()
{
/*#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
const char LL[]="%I64d\n";
#endif*/
n=read();
for (int i=1;i<=n;i++) a[i]=read();
for (int i=1;i<=n;i++) b[i]=read();
if (a[1]!=b[1]||a[n]!=b[n]) {cout<<"No";return 0;}
for (int i=n;i>=1;i--) a[i]-=a[i-1];
for (int i=n;i>=1;i--) b[i]-=b[i-1];
sort(a+1,a+n+1);
sort(b+1,b+n+1);
for (int i=1;i<=n;i++) if (a[i]!=b[i]) {cout<<"No";return 0;}
cout<<"Yes";
return 0;
//NOTICE LONG LONG!!!!!
}

  D:注意到一定存在最优方案使得同种顺子最多出两次。然后就是普及组dp了。我这种弱智怎么可能注意的到啊。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define N 1000010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int n,m,u,a[N],f[N][3][3];
signed main()
{
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
const char LL[]="%I64d\n";
#endif
n=read(),m=read();
for (int i=1;i<=n;i++) a[read()]++;
memset(f,200,sizeof(f));
f[0][0][0]=0;
for (int i=1;i<=m+2;i++)
for (int j=0;j<=2;j++)
for (int k=0;k<=2;k++)
for (int x=0;x<=2;x++)
if (k<=a[i]&&j+k<=a[i-1]&&j+k+x<=a[i-2])
f[i][j][k]=max(f[i][j][k],f[i-1][x][j]+x+(a[i-2]-j-k-x)/3);
cout<<f[m+2][0][0];
return 0;
//NOTICE LONG LONG!!!!!
}

  F:对dfs序建线段树维护当前点到每个点的距离(非叶子设为inf),询问按dfs序离线,然后整棵树dfs一遍并维护距离即可,这个维护仅仅是线段树上的区间加和区间减。我觉得比D简单多了!算了云选手没资格说话。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define N 500010
#define inf 100000000000000000ll
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int n,m,fa[N],p[N],len[N],dfn[N],id[N],L[N<<2],R[N<<2],size[N],t,cnt,cur;
ll deep[N],ans[N],tree[N<<2],lazy[N<<2];
struct data
{
int to,len;
bool operator <(const data&a) const
{
return to<a.to;
}
};
vector<data> edge[N];
struct data2
{
int x,l,r,i;
bool operator <(const data2&a) const
{
return dfn[x]<dfn[a.x];
}
}q[N];
void addedge(int x,int y,int z){edge[x].push_back((data){y,z});}
void dfs(int k)
{
dfn[k]=++cnt;id[cnt]=k;size[k]=1;
for (int i=0;i<edge[k].size();i++)
{
deep[edge[k][i].to]=deep[k]+edge[k][i].len;
dfs(edge[k][i].to);
size[k]+=size[edge[k][i].to];
}
if (edge[k].size()) deep[k]=inf;
}
void up(int k){tree[k]=min(tree[k<<1],tree[k<<1|1]);}
void build(int k,int l,int r)
{
L[k]=l,R[k]=r;
if (l==r)
{
tree[k]=deep[id[l]];
return;
}
int mid=l+r>>1;
build(k<<1,l,mid);
build(k<<1|1,mid+1,r);
up(k);
}
void update(int k,ll x){tree[k]+=x;lazy[k]+=x;}
void down(int k){update(k<<1,lazy[k]),update(k<<1|1,lazy[k]),lazy[k]=0;}
void add(int k,int l,int r,int x)
{
if (l>r) return;
if (L[k]==l&&R[k]==r) {update(k,x);return;}
if (lazy[k]) down(k);
int mid=L[k]+R[k]>>1;
if (r<=mid) add(k<<1,l,r,x);
else if (l>mid) add(k<<1|1,l,r,x);
else add(k<<1,l,mid,x),add(k<<1|1,mid+1,r,x);
up(k);
}
ll query(int k,int l,int r)
{
if (L[k]==l&&R[k]==r) return tree[k];
if (lazy[k]) down(k);
int mid=L[k]+R[k]>>1;
if (r<=mid) return query(k<<1,l,r);
else if (l>mid) return query(k<<1|1,l,r);
else return min(query(k<<1,l,mid),query(k<<1|1,mid+1,r));
}
void work(int k)
{
while (k==q[cur+1].x) cur++,ans[q[cur].i]=query(1,q[cur].l,q[cur].r);
for (int i=0;i<edge[k].size();i++)
{
int to=edge[k][i].to;
add(1,dfn[to],dfn[to]+size[to]-1,-edge[k][i].len);
add(1,1,dfn[to]-1,edge[k][i].len);
add(1,dfn[to]+size[to],n,edge[k][i].len);
work(to);
add(1,dfn[to],dfn[to]+size[to]-1,edge[k][i].len);
add(1,1,dfn[to]-1,-edge[k][i].len);
add(1,dfn[to]+size[to],n,-edge[k][i].len);
}
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif
n=read(),m=read();
for (int i=2;i<=n;i++)
{
fa[i]=read();len[i]=read();
addedge(fa[i],i,len[i]);
}
for (int i=1;i<=n;i++) sort(edge[i].begin(),edge[i].end());
dfs(1);
for (int i=1;i<=m;i++) q[i].x=read(),q[i].l=read(),q[i].r=read(),q[i].i=i;
sort(q+1,q+m+1);
build(1,1,n);
work(1);
for (int i=1;i<=m;i++) printf("%I64d\n",ans[i]);
return 0;
//NOTICE LONG LONG!!!!!
}

  div1+div2的场从来没进过前400,自闭了。

  result:rank 420 rating +22

Codeforces Global Round 1 自闭记的更多相关文章

  1. Codeforces Global Round 1 (CF1110) (未完结,只有 A-F)

    Codeforces Global Round 1 (CF1110) 继续补题.因为看见同学打了这场,而且涨分还不错,所以觉得这套题目可能会比较有意思. 因为下午要开学了,所以恐怕暂时不能把这套题目补 ...

  2. CodeForces Global Round 1

    CodeForces Global Round 1 CF新的比赛呢(虽然没啥区别)!这种报名的人多的比赛涨分是真的快.... 所以就写下题解吧. A. Parity 太简单了,随便模拟一下就完了. B ...

  3. Codeforces Global Round 1 - D. Jongmah(动态规划)

    Problem   Codeforces Global Round 1 - D. Jongmah Time Limit: 3000 mSec Problem Description Input Out ...

  4. Codeforces Global Round 2 题解

    Codeforces Global Round 2 题目链接:https://codeforces.com/contest/1119 A. Ilya and a Colorful Walk 题意: 给 ...

  5. Codeforces Global Round 1 (A-E题解)

    Codeforces Global Round 1 题目链接:https://codeforces.com/contest/1110 A. Parity 题意: 给出{ak},b,k,判断a1*b^( ...

  6. Codeforces Global Round 3

    Codeforces Global Round 3 A. Another One Bites The Dust 有若干个a,有若干个b,有若干个ab.你现在要把这些串拼成一个串,使得任意两个相邻的位置 ...

  7. 【手抖康复训练1 】Codeforces Global Round 6

    [手抖康复训练1 ]Codeforces Global Round 6 总结:不想复习随意打的一场,比赛开始就是熟悉的N分钟进不去时间,2333,太久没写题的后果就是:A 题手抖过不了样例 B题秒出思 ...

  8. Codeforces Global Round 11 个人题解(B题)

    Codeforces Global Round 11 1427A. Avoiding Zero 题目链接:click here 待补 1427B. Chess Cheater 题目链接:click h ...

  9. 【Codeforces Round 1110】Codeforces Global Round 1

    Codeforces Round 1110 这场比赛只做了\(A\).\(B\).\(C\),排名\(905\),不好. 主要的问题在\(D\)题上,有\(505\)人做出,但我没做出来. 考虑的时候 ...

随机推荐

  1. C# Socket的粘包处理

    当socket接收到数据后,会根据buffer的大小一点一点的接收数据,比如: 对方发来了1M的数据量过来,但是,本地的buffer只有1024字节,那就代表socket需要重复很多次才能真正收完这逻 ...

  2. HBase篇(1)-特性与应用场景

    [每日五分钟搞定大数据]系列,HBase第一篇 结束了Zookeeper篇, 接下来我们来说下Google三驾马车之一BigTable的开源实现:HBase,要讲的内容暂定如下: 这是第一篇我们先不聊 ...

  3. 两篇 Spring 总结(一)

    Spring4 概述以及 HelloWorld 概述 Spring 是一个 IOC(DI) 和 AOP 容器框架. 轻量级,Spring 是非侵入的,即使用的时候不需要实现任何接口或继承任何父类 面向 ...

  4. 【深度学习】一文读懂机器学习常用损失函数(Loss Function)

    最近太忙已经好久没有写博客了,今天整理分享一篇关于损失函数的文章吧,以前对损失函数的理解不够深入,没有真正理解每个损失函数的特点以及应用范围,如果文中有任何错误,请各位朋友指教,谢谢~ 损失函数(lo ...

  5. 《React Native 精解与实战》书籍连载「React Native 网络请求与列表绑定」

    此文是我的出版书籍<React Native 精解与实战>连载分享,此书由机械工业出版社出版,书中详解了 React Native 框架底层原理.React Native 组件布局.组件与 ...

  6. .net core2 笔记

    资源: https://github.com/aspnet/home https://github.com/dotnet/cli https://www.cnblogs.com/billyang/p/ ...

  7. 如何在C#中使用Dapper(译)

    前言: 对象关系映射(ORM)已经被使用了很长时间,以解决在编程过程中对象模型与数据模型在关系数据库中不匹配的问题. Dapper是由Stack OverFlow团队开发的开源的,轻量级的ORM.相比 ...

  8. Python之发邮件

    使用模块yagmail(使用收藏的yagmail,现在的第三方模块不能解决中文乱码问题) import yagmail user='xxx@126.com' password='xxxxxx' #使用 ...

  9. Java Core - JVM运行时内存管理

    在读正文之前,阅读以下两篇博客学习并理解堆栈.作用域.本地方法的概念. 作用域:https://www.cnblogs.com/AlanLee/p/6627949.html 操作数栈:https:// ...

  10. ShowDoc上手

    ShowDoc是什么 每当接手一个他人开发好的模块或者项目,看着那些没有写注释的代码,我们都无比抓狂.文档呢?!文档呢?!Show me the doc !! 程序员都很希望别人能写技术文档,而自己却 ...