Codeforces Round #571 (Unrated for Div. 1+Div. 2)
A
略
B
被删了,被这个假题搞自闭了,显然没做出来。
C
开始莽了个NTT,后来发现会TLE,其实是个SB前缀和,对于这题,我无**说。
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+,mod=;
int n,m,ans,sum,s[N];
char a[N],b[N];
int main()
{
scanf("%s",a+),n=strlen(a+);
scanf("%s",b+),m=strlen(b+);
for(int i=;i<=n;i++)s[i]=s[i-]+(a[i]!=a[i-]);
for(int i=;i<=m;i++)sum+=a[i]!=b[i];
sum&=;
ans+=sum^;
for(int i=m+;i<=n;i++)
{
sum+=s[i]-s[i-m];
sum&=;
ans+=sum^;
}
printf("%d",ans);
}
D
我的做法是这样的:对于非整数,显然先把其下取整,发现比0小多少,然后发现能加几个值,贪心加即可。
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+;
int n,tot,a[N],b[N];
double sum;
double down(double x)
{
double ret=;
if(x>=)ret=trunc(x);else ret=trunc(x)-;
sum+=x-ret;
return ret;
}
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
double x;scanf("%lf",&x);
if(trunc(x)==x)a[i]=x;
else a[i]=down(x),b[i]=;
}
tot=sum+1e-;
for(int i=;i<=n&&tot;i++)if(b[i])tot--,a[i]++;
for(int i=;i<=n;i++)printf("%d\n",a[i]);
}
E
很容易发现每个(2n)*(2m)的矩阵和是一样的,不如直接扩展成(2n)*(2m),然后直接做一下就行了
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=;
int n,m,Q,s[N][N];
char str[N];
ll calc(int x,int y)
{
ll ret=(1ll*x*y-1ll*(x%n)*(y%m))/;
int t=x/n^y/m,num=;
while(t)num+=t&,t>>=;
if(num&)ret+=(x%n)*(y%m)-s[x%n][y%m];else ret+=s[x%n][y%m];
return ret;
}
int main()
{
scanf("%d%d%d",&n,&m,&Q);
for(int i=;i<=n;i++)
{
scanf("%s",str+);
for(int j=;j<=m;j++)s[i][j]=s[i+n][j+m]=str[j]-'',s[i+n][j]=s[i][j+m]=s[i][j]^;
}
n<<=,m<<=;
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
s[i][j]+=s[i-][j]+s[i][j-]-s[i-][j-];
while(Q--)
{
int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
printf("%I64d\n",calc(c,d)+calc(a-,b-)-calc(a-,d)-calc(c,b-));
}
}
F
显然从度数最小的点开始分配,然后贪心分配,即两端的点度数都不满就分配。然后xjb乱证明一通:∵Σdeg[i]=2m,所以Σ(deg[i]+1)/2<=Σdeg[i]/2+n<=m+n,于是发现每次分配度数不满的做法是可行的。
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+;
struct node{int u,v;};
bool operator<(node a,node b){return a.v>b.v;}
priority_queue<node>q;
int n,m,cnt,ret,tot,hd[N],v[N<<],nxt[N<<],w[N<<],mark[N],vis[N],deg[N],now[N],U[N],V[N];
void adde(int x,int y,int z){v[++cnt]=y,nxt[cnt]=hd[x],w[cnt]=z,hd[x]=cnt;}
int main()
{
scanf("%d%d",&n,&m);
for(int i=,x,y;i<=m;i++)
scanf("%d%d",&x,&y),U[i]=x,V[i]=y,adde(x,y,i),adde(y,x,i),deg[x]++,deg[y]++;
for(int i=;i<=n;i++)now[i]=deg[i];
ret=m;
for(int i=;i<=n;i++)q.push((node){i,deg[i]});
while(!q.empty())
{
if(ret<=(n+m+)/)break;
int u=q.top().u;q.pop();
if(vis[u])continue;
vis[u]=;
for(int i=hd[u];i&&now[u]!=(deg[u]+)/;i=nxt[i])
if(!mark[w[i]]&&now[v[i]]!=(deg[v[i]]+)/)
{
now[v[i]]--,now[u]--,ret--;
mark[w[i]]=;
q.push((node){v[i],now[v[i]]});
}
}
for(int i=;i<=m;i++)if(!mark[i])tot++;
printf("%d\n",tot);
for(int i=;i<=m;i++)if(!mark[i])printf("%d %d\n",U[i],V[i]);
}
Codeforces Round #571 (Unrated for Div. 1+Div. 2)的更多相关文章
- 【Codeforces Round 1129】Alex Lopashev Thanks-Round (Div. 1)
Codeforces Round 1129 这场模拟比赛做了\(A1\).\(A2\).\(B\).\(C\),\(Div.1\)排名40. \(A\)题是道贪心,可以考虑每一个站点是分开来的,把目的 ...
- Educational Codeforces Round 64(Unrated for Div.1+Div. 2)
什么垃圾比赛,A题说的什么鬼楞是没看懂.就我只会BD(其实C是个大水题二分),垃圾游戏,技不如人,肝败吓疯,告辞,口胡了E就睡觉了. B 很容易发现,存在一种方案,使得相同字母连在一起,然后发现,当字 ...
- Codeforces Round #571 (Div. 2)-D. Vus the Cossack and Numbers
Vus the Cossack has nn real numbers aiai. It is known that the sum of all numbers is equal to 00. He ...
- Codeforces Round #571 (Div. 2)
A. Vus the Cossack and a Contest 签. #include <bits/stdc++.h> using namespace std; int main() { ...
- Vus the Cossack and Strings(Codeforces Round #571 (Div. 2))(大佬的位运算实在是太强了!)
C. Vus the Cossack and Strings Vus the Cossack has two binary strings, that is, strings that consist ...
- Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2) C D
C - Maximum Subrectangle 因为是两个数组相乘的到的 矩阵所以 a(i ->j)*b(x->y) 的面积 就是 a(i ->j) 的和乘与b(x-> ...
- [Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2) ](A~E)
A: 题目大意:给你一个数字串,每个数字只可以用一次,求最多可以组成多少个电话号码(可以相同),电话号码第一个数字为$8$,且长度为$11$ 题解:限制为$8$的个数和总长度,直接求 卡点:无 C++ ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3)(A.B.C,3道暴力题,C可二分求解)
A. Is it rated? time limit per test:2 seconds memory limit per test:256 megabytes input:standard inp ...
- Codeforces Round#412 Div.2
A. Is it rated? 题面 Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codefo ...
随机推荐
- 用四种方法将两个AJAX改为同步
用四种方法将两个AJAX改为同步 Promise.Generator函数.yield.async/await 相关 今有一题,题目为: 现有ajax1()和ajax2(),用于快速初始化CODE1和C ...
- ruby资料
源码样例 链接: https://pan.baidu.com/s/1mh55bFM 密码: 6cjy 初级代码 链接: https://pan.baidu.com/s/1hschnUW 密码: 8n1 ...
- P1040 有几个PAT
转跳点:
- SQL 、LINQ日前比较
using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; ...
- OIer常见问题与错误总结
作为一名OIer,无论是一名刚入门的蒟蒻,还是叱诧风云的神犇,相信都会难免去犯一些错误(废话不犯错误岂不是都满分了(ノへ ̄.).在这里总结了一些OIer常见易犯的错误,与大家共勉. 1.正常错误 可能 ...
- Java中的super关键字和this关键字作用介绍
一.super关键字的作用 1.子类在构造方法中显示调用父类构造方法 super可以在子类的构造方法中显示调用父类的构造方法:并且这行代码必须出现在子类构造方法的第一行.原因:因为父类构造方法没有执行 ...
- 【Python】【Django】登录用户-链接Mysql
- android——TextView默认文字开发时显示运行时隐藏
根布局添加属性: xmlns:tools="http://schemas.android.com/tools" textview添加属性: tools:text="默认文 ...
- LA_4730 Kingdom 并查集+树状数组
给定N个点的坐标,代表N各城市,有M种操作,共分两种,一种是连线,把两个点连起来(一旦构成连通图,这个连通图即为一个州),还有种询问操作,为y=c,(c为小数部分恒为.5的实数),问y=c这条线经过了 ...
- 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:第一个Spring程序
1. 创建项目 在 MyEclipse 中创建 Web 项目 springDemo01,将 Spring 框架所需的 JAR 包复制到项目的 lib 目录中,并将添加到类路径下,添加后的项目如图 2. ...