首页 > 其他 > 详细

Codeforces Round #564 比赛总结

时间:2019-06-08 10:59:15      阅读:116      评论:0      收藏:0      [点我收藏+]

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

A. Nauuo and Votes

技术分享图片
 1 #include<bits/stdc++.h>
 2 #define Rint register int
 3 using namespace std;
 4 typedef long long LL;
 5 int x, y, z;
 6 int main(){
 7     scanf("%d%d%d", &x, &y, &z);
 8     if(x + z - y < 0) puts("-");
 9     else if(x - y - z > 0) puts("+");
10     else if(x == y && z == 0) puts("0");
11     else puts("?");
12 }
CF1173A

B. Nauuo and Chess

技术分享图片
 1 #include<bits/stdc++.h>
 2 #define Rint register int
 3 using namespace std;
 4 typedef long long LL;
 5 int n, m;
 6 int main(){
 7     scanf("%d", &n);
 8     m = (n >> 1) + 1;
 9     printf("%d\n", m);
10     for(Rint i = 1;i <= m;i ++)
11         printf("%d %d\n", 1, i);
12     for(Rint i = 2;i <= n - m + 1;i ++)
13         printf("%d %d\n", i, m);
14 }
CF1173B

C. Nauuo and Cards

(这题还不会,就不管它了)

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!$$

技术分享图片
 1 #include<bits/stdc++.h>
 2 #define Rint register int
 3 using namespace std;
 4 typedef long long LL;
 5 const int N = 200003, mod = 998244353;
 6 int n, fac[N], deg[N], ans;
 7 int main(){
 8     scanf("%d", &n);
 9     for(Rint i = 1;i < n;i ++){
10         int a, b;
11         scanf("%d%d", &a, &b);
12         deg[a] ++; deg[b] ++;
13     }
14     fac[0] = ans = 1;
15     for(Rint i = 1;i <= n;i ++) fac[i] = (LL) i * fac[i - 1] % mod;
16     for(Rint i = 1;i <= n;i ++) ans = (LL) ans * fac[deg[i]] % mod;
17     printf("%d\n", (LL) ans * n % mod);
18 }
CF1137D

 

Codeforces Round #564 比赛总结

原文:https://www.cnblogs.com/AThousandMoons/p/10989460.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!