题目链接  Round 439 div2

就做了两道题TAT

开场看C题就不会

然后想了好久才想到。

三种颜色挑出两种算方案数其实是独立的,于是就可以乘起来了。

E题想了一会有了思路,然后YY出了一种方案。

我们可以对每个矩形随机一个权值,然后用二维树状数组搞下。

询问的时候看两个点权值是否相等就可以了

于是就过了。

D题待补

给出一棵完全二叉树,这棵树上有附带的m条边(m <= 4),求这张图的简单路径条数。

qls的题就是厉害……

C题

#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b)	for (int i(a); i <= (b); ++i)
#define dec(i, a, b) for (int i(a); i >= (b); --i)
#define MP make_pair
#define fi first
#define se second typedef long long LL; const int N = 5010; const int mod = 998244353; int P[N][N], C[N][N];
int a, b, c; int calc(int x, int y){
if (x > y) swap(x, y);
LL ret = 0;
rep(i, 0, x) ret = (ret + 1ll * P[y][i] * C[x][i]) % mod;
return ret;
} int main(){ C[0][0] = P[0][0] = 1;
scanf("%d%d%d", &a, &b, &c); rep(i, 1, 5000){
C[i][0] = P[i][0] = 1;
rep(j, 1, i){
P[i][j] = (1ll * P[i - 1][j - 1] * j % mod + 1ll * P[i - 1][j] % mod) % mod;
C[i][j] = (1ll * C[i - 1][j - 1] + 1ll * C[i - 1][j]) % mod;
}
} int ans = 1ll * calc(a, b) % mod * 1ll * calc(b, c) % mod * 1ll * calc(a, c) % mod;
printf("%d\n", ans);
return 0;
}

E题

#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b)	for (int i(a); i <= (b); ++i)
#define dec(i, a, b) for (int i(a); i >= (b); --i)
#define MP make_pair typedef long long LL;
typedef pair <int, int> PII; const LL mod = 1e9 + 7;
const int N = 5010; map <PII, LL> mp; int cnt = 0;
int n, m, q;
int p[N][N];
LL c[N][N]; inline void add(int x, int y, LL val){
for (; x <= n; x += x & -x){
for (int t = y; t <= m; t += t & -t){
c[x][t] = (c[x][t] + val) % mod;
c[x][t] = (c[x][t] + mod) % mod;
}
}
} inline LL query(int x, int y){
LL ret = 0;
for (; x ; x -= x & -x){
for (int t = y; t ; t -= t & -t){
(ret += c[x][t]) %= mod;
}
} return ret;
} inline LL solve(int x, int y){
LL ret = query(x, y) % mod;
return ret;
} int main(){ scanf("%d%d%d", &n, &m, &q);
rep(i, 1, n) rep(j, 1, m) p[i][j] = ++cnt; rep(i, 1, q){
int op;
scanf("%d", &op);
if (op == 1){
int x1, y1, x2, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
if (x1 > x2) swap(x1, x2);
if (y1 > y2) swap(y1, y2);
LL cnt = (LL)rand() * (LL)rand() * (LL)rand() % mod;
mp[MP(p[x1][y1], p[x2][y2])] = cnt; add(x1, y1, cnt);
add(x1, y2 + 1, -cnt);
add(x2 + 1, y1, -cnt);
add(x2 + 1, y2 + 1, cnt);
} else if (op == 2){
int x1, y1, x2, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
if (x1 > x2) swap(x1, x2);
if (y1 > y2) swap(y1, y2);
LL cnt = mp[MP(p[x1][y1], p[x2][y2])];
add(x1, y1, -cnt);
add(x1, y2 + 1, cnt);
add(x2 + 1, y1, cnt);
add(x2 + 1, y2 + 1, -cnt);
} else{
int x1, y1, x2, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
LL xx = solve(x1, y1);
LL yy = solve(x2, y2);
if (xx == yy) puts("Yes");
else puts("No");
} } return 0;
}

Codeforces Round #439 (Div. 2) 题解的更多相关文章

  1. Codeforces Round #439 (Div. 2)【A、B、C、E】

    Codeforces Round #439 (Div. 2) codeforces 869 A. The Artful Expedient 看不透( #include<cstdio> in ...

  2. Codeforces Round #182 (Div. 1)题解【ABCD】

    Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...

  3. Codeforces Round #608 (Div. 2) 题解

    目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...

  4. Codeforces Round #525 (Div. 2)题解

    Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...

  5. Codeforces Round #528 (Div. 2)题解

    Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...

  6. Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F

    Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...

  7. Codeforces Round #677 (Div. 3) 题解

    Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...

  8. Codeforces Round #665 (Div. 2) 题解

    Codeforces Round #665 (Div. 2) 题解 写得有点晚了,估计都官方题解看完切掉了,没人看我的了qaq. 目录 Codeforces Round #665 (Div. 2) 题 ...

  9. Codeforces Round #160 (Div. 1) 题解【ABCD】

    Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须 ...

随机推荐

  1. python3 发邮件 smtplib & email 库

    嗨 实现了用163发送到qq的功能,遗留了两个问题: 1. 接收者list会报错:update:因为list[]会传递过去一个真的[]list,改成如下就可以了: before: maillist=[ ...

  2. Python头脑风暴2

    今天想到了一个致富新途径:假如我在X东上班,我写个X宝爬虫,专门爬在X宝买奢侈品的土豪,然后我自己注册个X宝号,用脚本一个个加他们然后给他们发信息说我X东这还有比你更便宜更好的...不知道行不行啊(狗 ...

  3. Django之用户认证

    用户认证组件简介 功能:用session记录登录验证状态 前提:必须使用django自带的auth_user表.那这里有的同学就会有疑问了,自己不能创建自己的用户表吗? 当然可以,用户认证组件虽然只针 ...

  4. HDU - 6199 gems gems gems (DP)

    有n(2e4)个宝石两个人轮流从左侧取宝石,Alice先手,首轮取1个或2个宝石,如果上一轮取了k个宝石,则这一轮只能取k或k+1个宝石.一旦不能再取宝石就结束.双方都希望自己拿到的宝石数比对方尽可能 ...

  5. hdu3487Play with Chain

    Play with Chain Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  6. 当列表推导式遇到lambda(匿名函数)

    Python这么优雅的语言,我也是醉了...... 事情由一段代码引发,请看: 上述的列表推导式+lambda表达式+for循环,他们碰撞出来的结果搞的人晕头转向,咱们逐步来分析一下他们到底是个什么鬼 ...

  7. Xpath - Xpath定位

     selenium 提供的xpath定位方法名为:find_element_by_xpath(xpath表达式) Xpath基本定位语法: / 绝对定位,从根节点选取 // 相对定位,从匹配选择的当前 ...

  8. hihoCoder #1246 王胖浩与环

    题目大意 $n$($1\le n\le 2000$)个正整数 $a_1, a_2, \dots, a_n$($a_i\le 5\times 10^7$)分布在一个圆环上. 定义 $b_k$ 为:将环上 ...

  9. ACM程序设计选修课——1036: Hungar的菜鸟赛季(YY)

    1036: Hungar的菜鸟赛季 Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 20  Solved: 14 [Submit][Status][Web ...

  10. [luoguP2336] [SCOI2012]喵星球上的点名(后缀数组 + 暴力)

    传送门 原本的想法是把所有的串不管是名字还是询问都连起来,记录一下询问串在sa数组中的位置 对于每个询问可以在sa数组中二分出左右边界,第一问用莫队,第二问差分乱搞. 结果发现我差分的思路想错了,先写 ...