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

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. Spring (1)框架

    Spring第一天笔记   1. 说在前面 怎样的架构的程序,我们认为是一个优秀的架构? 我们考虑的标准:可维护性好,可扩展性好,性能. 什么叫可扩展性好? 答:就是可以做到,不断的增加代码,但是可以 ...

  2. ligerui tab 部分记载

    打开一个Tab $(".strength_box").click(function () { var id = $(this).attr("data"); va ...

  3. Java 实现简单的 RPC 框架

    RPC 简介 RPC,全称为 Remote Procedure Call,即远程过程调用,它是一个计算机通信协议.它允许像调用本地服务一样调用远程服务.它可以有不同的实现方式,而不需要了解底层网络技术 ...

  4. aspnet core 全局模型验证,统一api响应

    上手就来 新建一个模型验证过滤器,其中ApiResp是自定义的统一响应类. public class VldFilter:IActionFilter { /// <summary> /// ...

  5. opencv-02--图像的邻域操作

    图像的邻域操作 很多时候,我们对图像处理时,要考虑它的邻域,比如3*3是我们常用的,这在图像滤波.去噪中最为常见,下面我们介绍如果在一次图像遍历过程中进行邻域的运算. 下面我们进行一个简单的滤波操作, ...

  6. keras 切换后端 TensorFlow,cntk,theano

    参考 https://keras.io/#configuring-your-keras-backend https://keras.io/backend/ Switching from one bac ...

  7. Hibernate-validate工具类,手动调用校验返回结果

    引言:在常见的工程中,一般是在Controller中校验入参,校验入参的方式有多种,这里介绍的使用hibernate-validate来验证,其中分为手动和自动校验,自动校验可以联合spring,使用 ...

  8. 8.读写锁ReadWriteLock

    /*ReadWriteLock 读写锁*/ private ReadWriteLock lock = new ReentrantReadWriteLock(); lock.readLock().loc ...

  9. Personalize Oracle Applications Home Page Browser Window Title

    修改登录页 http://expertoracle.com/2016/03/10/personalizing-the-e-business-suite-r12-login-page/ STEP 2 : ...

  10. 理解JVM之垃圾回收

    1.垃圾收集算法 1) 标记-清楚算法:该算法是最基础的收集算法,其分为标记与清除两个阶段.首先标记出所有需要回收的对象,在标记完成后统一回收所有被标记的对象,该算法主要有两个不足:一个是效率问题,标 ...