这次是中国大佬出题,结果被虐惨了。

A. Nauuo and Votes

 #include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
int x, y, z;
int main(){
scanf("%d%d%d", &x, &y, &z);
if(x + z - y < ) puts("-");
else if(x - y - z > ) puts("+");
else if(x == y && z == ) puts("");
else puts("?");
}

CF1173A

B. Nauuo and Chess

 #include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
int n, m;
int main(){
scanf("%d", &n);
m = (n >> ) + ;
printf("%d\n", m);
for(Rint i = ;i <= m;i ++)
printf("%d %d\n", , i);
for(Rint i = ;i <= n - m + ;i ++)
printf("%d %d\n", i, m);
}

CF1173B

C. Nauuo and Cards

(乱搞能力有待加强)

首先我们分两种情况,手上会拿到1和不会拿到1.

对于后者,初始的时候1要在队列中并且它之后是$2,3,4,\ldots,i-1$,然后之后可以把$i,i+1,\ldots,n$放进队列中,需要$n-i+1$步。

对于前者,用$p_i$表示$i$初始在队列的位置,不在则为0,也就是至少$p_i$步之后可以拿到这张牌,将$i$从$p_i$这个位置转移到$i$需要$p_i-i+n+1$步,取最大值即为答案。

感性理解:首先如果后者可以那么后者一定比前者更优,对于前者,我们可以通过先扔一些空牌来拿到足够的牌,然后依次把$1,2,3,\ldots n$扔出去,不会更优。

 #include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = ;
int n, a[N], b[N], p[N], ans;
int main(){
scanf("%d", &n);
for(Rint i = ;i <= n;i ++){
scanf("%d", a + i); p[a[i]] = ;
}
for(Rint i = ;i <= n;i ++){
scanf("%d", b + i); p[b[i]] = i;
}
if(p[]){
int i, j;
for(i = ;p[i] == p[] + i - ;i ++);
if(p[i - ] == n){
for(j = i;j <= n && p[j] <= j - i;j ++);
if(j > n){
printf("%d\n", n - i + );
return ;
}
}
}
for(Rint i = ;i <= n;i ++) ans = max(ans, p[i] - i + n + );
printf("%d", ans);
}

CF1172A

D. Nauuo and Circle

我们发现,对于节点$x$的子树,它在排列中必定是一段连续的区间,否则就会跟其他的子树导致边相交。

这个排列是可以旋转的,所以钦定$p_1=1$。

设节点$i$的度数为$deg_i$。

我们使用捆绑法,将必须要连在一起的先捆绑起来,之后再对子树进行递归。

例如样例1,2就是这样的:

$$(1,(2,4),3)$$

$$(1,2,3,4)$$

(同个括号里的表示必须要连续)

对于节点$1$,我们可以任意排列它的$deg_1$棵子树,对于其他节点$x$,我们可以排列它自己和$deg_x-1$棵子树

$$Ans=n\prod_{i=1}^ndeg_i!$$

 #include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = , mod = ;
int n, fac[N], deg[N], ans;
int main(){
scanf("%d", &n);
for(Rint i = ;i < n;i ++){
int a, b;
scanf("%d%d", &a, &b);
deg[a] ++; deg[b] ++;
}
fac[] = ans = ;
for(Rint i = ;i <= n;i ++) fac[i] = (LL) i * fac[i - ] % mod;
for(Rint i = ;i <= n;i ++) ans = (LL) ans * fac[deg[i]] % mod;
printf("%d\n", (LL) ans * n % mod);
}

CF1137D

Codeforces Round #564 比赛总结的更多相关文章

  1. Codeforces Round #564 (Div. 1)

    Codeforces Round #564 (Div. 1) A Nauuo and Cards 首先如果牌库中最后的牌是\(1,2,\cdots, k\),那么就模拟一下能不能每次打出第\(k+i\ ...

  2. Codeforces Round #564(div2)

    Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...

  3. Codeforces Round #564 (Div. 2) C. Nauuo and Cards

    链接:https://codeforces.com/contest/1173/problem/C 题意: Nauuo is a girl who loves playing cards. One da ...

  4. Codeforces Round #564 (Div. 2) B. Nauuo and Chess

    链接:https://codeforces.com/contest/1173/problem/B 题意: Nauuo is a girl who loves playing chess. One da ...

  5. Codeforces Round #564 (Div. 2) A. Nauuo and Votes

    链接:https://codeforces.com/contest/1173/problem/A 题意: Nauuo is a girl who loves writing comments. One ...

  6. Codeforces Round #564 (Div. 2)B

    B. Nauuo and Chess 题目链接:http://codeforces.com/contest/1173/problem/B 题目 Nauuo is a girl who loves pl ...

  7. Codeforces Round #564 (Div. 2)A

    A. Nauuo and Votes 题目链接:http://codeforces.com/contest/1173/problem/A 题目 Nauuo is a girl who loves wr ...

  8. Educational Codeforces Round 77 比赛总结

    比赛情况 我太菜了 A题 加减乘除不会 B题 二元一次方程不会 C题 gcd不会 就会一个D题二分答案大水题,本来想比赛最后一分钟来一个绝杀,结果 Wrong Answer on test 4 比赛总 ...

  9. Codeforces Round 564 题解

    很抱歉让标题把您骗进来了. 这是一场打得最失败的div1. 作为一个橙名一题都不会…… 旁边紫名的PB怒切3题,div2的也随便玩玩出了div1b/div2d…… 这名字颜色也太有水分了. 也就只会2 ...

随机推荐

  1. ASP.NET Core分布式项目-2.oauth密码模式identity server4实现

    源码下载 这里根据<ASP.NET Core分布式项目-1.IdentityServer4登录中心>的代码来继续更新oauth密码模式,这里的密码模式比上次的客户端模式更安全 在WebAp ...

  2. Qt实现艺术字效果

    Qt实现艺术字效果,通常有三种方式,一种是通过绘制机制,另外一种是使用样式表,最后一种是通过图片代替,本次介绍使用绘制来实现艺术字效果. 代码如下(分两种实现): 第一种: QPainter pain ...

  3. php 配置微信公众号

    首先你要在微信公众号官网申请一个公众号,然后登录进去 在网页的左下方找到开发的基本配置 就可以开始配置服务器下面的东西了 点击打开成这个样子的 就是一些参数,url填写你自己服务器的具体地址就好了,我 ...

  4. css 清除浮动 & BFC

    前言:这是笔者学习之后自己的理解与整理.如果有错误或者疑问的地方,请大家指正,我会持续更新! 文档流的概念:html 中 block 块元素默认是单独占据一行的,从上到下排列,也就是我们说的文档流. ...

  5. (七)shiro之编码/加密

    一.编码/解码 使用Base64编码/解码操作 public class TestMain { public static void main(String[] args) { SecurityMan ...

  6. string+DFS leetcode-17.电话号码下的字母组合

    题面 Given a string containing digits from 2-9 inclusive, return all possible letter combinations that ...

  7. leetcode-3 最长无重复字串

    3. Longest Substring Without Repeating Characters 题面 Given a string, find the length of the longest ...

  8. linux——运维基础,与常用命令

    1 运维概述 1 什么是运维 服务器的运行维护 2 名词 IDC(互联网数据中心) 3 监控软件 zabbix(用的最多), nagios, cactti 4 常用的linux操作系统 1 CentO ...

  9. Vs2017 NetCode Mvc EF Mysql 整合2

    1 NetCode EF整合 代码 3  源代码 https://github.com/chxl800/EFMysqlDemo 1.1 项目文件结构 1.2 NuGet  MySql.Data.Ent ...

  10. 微信中浏览器支持input调用摄像头和只能上传图片

    <input type="file" capture="camera" accept="image/*" />