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)的更多相关文章

  1. 【Codeforces Round 1129】Alex Lopashev Thanks-Round (Div. 1)

    Codeforces Round 1129 这场模拟比赛做了\(A1\).\(A2\).\(B\).\(C\),\(Div.1\)排名40. \(A\)题是道贪心,可以考虑每一个站点是分开来的,把目的 ...

  2. Educational Codeforces Round 64(Unrated for Div.1+Div. 2)

    什么垃圾比赛,A题说的什么鬼楞是没看懂.就我只会BD(其实C是个大水题二分),垃圾游戏,技不如人,肝败吓疯,告辞,口胡了E就睡觉了. B 很容易发现,存在一种方案,使得相同字母连在一起,然后发现,当字 ...

  3. 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 ...

  4. Codeforces Round #571 (Div. 2)

    A. Vus the Cossack and a Contest 签. #include <bits/stdc++.h> using namespace std; int main() { ...

  5. 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 ...

  6. 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-> ...

  7. [Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2) ](A~E)

    A: 题目大意:给你一个数字串,每个数字只可以用一次,求最多可以组成多少个电话号码(可以相同),电话号码第一个数字为$8$,且长度为$11$ 题解:限制为$8$的个数和总长度,直接求 卡点:无 C++ ...

  8. 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 ...

  9. Codeforces Round#412 Div.2

    A. Is it rated? 题面 Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codefo ...

随机推荐

  1. Linux学习《第四章脚本》20200222

  2. 74.Python中ORM聚合函数详解:Max,Min

    Max和Min:获取指定对象的最大值和最小值. 1. 比如:想要获取Author表中的最大的年龄和最小的年龄.示例代码如下: from django.http import HttpResponse ...

  3. 152-PHP htmlspecialchars函数

    <?php //定义一个HTML代码字符串 $str=<<<HTM <a href=#><b><i>到一个网址的链接<>< ...

  4. Java 归并排序

    package cookie; public class MergeSort { void mergeSort(int[] a, int[] temp, int left, int right) { ...

  5. maven详解之仓库

    在Maven中,任何一个依赖.插件或者项目构建的输出,都可以称之为构件. Maven在某个统一的位置存储所有项目的共享的构件,这个统一的位置,我们就称之为仓库.(仓库就是存放依赖和插件的地方) 任何的 ...

  6. Java中的super关键字和this关键字作用介绍

    一.super关键字的作用 1.子类在构造方法中显示调用父类构造方法 super可以在子类的构造方法中显示调用父类的构造方法:并且这行代码必须出现在子类构造方法的第一行.原因:因为父类构造方法没有执行 ...

  7. Spring开发环境搭建(Eclipse)

    开发环境搭建,主要包含2部分: Java安装 Eclipse安装 为易于学习,我们只安装这2个部分,对于一般开发学习也足够了.如果你有其他要安装的,酌情添加. Java安装 我们使用Java8: 下载 ...

  8. hdu 3790 最短路径dijkstra(多重权值)

    最短路径问题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  9. ES6 新特性(笔记)

    1.定义变量     let         a).块作用域 , 不同于var的函数作用域         b).不可以重复定义同一个变量名           注:              {} ...

  10. vue学习(十二)vue全家桶 Vue-router&Vuex

    一 vue-router的安装 二 vue-router的基本使用 三 命名路由 四 动态路由的匹配和路由组件的复用 一 vue-router的安装 NPM npm install vue-route ...