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每日练习-复习紧急救援模式下重改root权限密码 20200225

  2. 找不到xml、找不到类

    解决java.lang.ClassNotFoundException  解决 java.io.FileNotFoundException: class path resource [xxx.xml] ...

  3. 2.13 ViewModel 使数据即使在后台被杀死数据也能存活

    操作程序如下: 主要是创建一个 SavedStateHandle 来缓存上一次的数据,并通过重新读取上一次存储的数据来实现数据的存活 MyVIewModel: package com.example. ...

  4. 044-PHP获得多个类对应的反射信息

    <?php //获得多个类对应的反射信息 class demo{ public $str_1; private $str_2; protected $str_3; public function ...

  5. Lombok认知

    Lombok的简介 Lombok是一款Java开发插件,公司项目到处使用,整体效果很棒,代码更干净.Java开发人员可以节省出重复构建,诸如hashCode和equals这样的方法以及各种业务对象模型 ...

  6. 错误:selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities

    错误再现 原因:firefox浏览器版本和浏览器驱动版本不匹配 解决办法:卸载高版本浏览器,安装低版本浏览器

  7. mysql多表关联更新

    update 表A inner join 表B on 表A.关联字段 = 表B.关联字段 set 表a.待更新字段01 = 表B.字段01 , 表a.待更新字段021 = 表B.字段02 where ...

  8. Python LMDB的使用

    在python中使用lmdb linux中,可以使用指令 pip install lmdb 安装lmdb包. ---- lmdb 数据库文件生成 增 改 删 查 1.生成一个空的lmdb数据库文件 # ...

  9. 【剑指Offer】面试题10- II. 青蛙跳台阶问题

    题目 一只青蛙一次可以跳上1级台阶,也可以跳上2级台阶.求该青蛙跳上一个 n 级的台阶总共有多少种跳法. 答案需要取模 1e9+7(1000000007),如计算初始结果为:1000000008,请返 ...

  10. JSP标签 <fmt:formatDate>格式化日期

    <fmt:formatDate>标签用于使用不同的方式格式化日期. <%@ page language="java" contentType="text ...