Codeforces Round # 564 Tournament Summary

This is the Chinese Gangster topic, the results abused miserable.

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

(This question will not, leave it there)

D. Nauuo and Circle

We found that sub-tree node $ x $, and it must be arranged in a contiguous range, otherwise it will lead to sub-tree with the other side of the intersection.

This arrangement can be rotated, so Imperial $ p_1 = 1 $.

$ I $ disposed node degree is $ deg_i $.

We use bundling method, you would have to be linked to the first tied up, and then after the sub-tree recursively.

Sample 1 is for example like this:

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

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

(With a parentheses indicate that you must be continuous)

For node $ 1 $, we can arrange any of its $ deg_1 $ subtrees for the other node $ x $, we can arrange it yourself and $ deg_x-1 $ subtrees

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

 

Guess you like

Origin www.cnblogs.com/AThousandMoons/p/10989460.html