题目链接  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. 20181206(re,正则表达式,哈希)

    1.re&正则表达式 2.hashlib 一:re模块&正则表达式 正则:正则就是用一些具有特殊含义的符号组合到一起(称为正则表达式)来描述字符或者字符串的方法.或者说:正则就是用来描 ...

  2. linux下安装mysql并设置远程连接

    腾讯云环境为Centos7.4   mysql版本为5.6 本次安装使用yum安装 检查是否已有mysql: yum list installed | grep mysql 下载yum源文件: wge ...

  3. leetcode-16-greedyAlgorithm

    455. Assign Cookies 解题思路: 先将两个数组按升序排序,然后从后往前遍历,当s[j] >= g[i]的时候,就把s[j]分给g[i],i,j都向前移动,count+1;否则向 ...

  4. Java观察者模式(Observer)

    一.定义 观察者模式定义了一种一对多的依赖关系,让多个观察者对象同时监听某一个主题对象.这个主题对象在状态上发生变化时,会通知所有观察者对象,让他们能够自动更新自己.主要应用在java的AWT事件机制 ...

  5. Centos7重启网卡失败解决方法

    service Network-Manager stop  执行命令解决,如果执行命令还是失败,则是配置文件内容的问题,检查配置文件

  6. Python虚拟机中的一般表达式(一)

    在Python虚拟机框架这一章中,我们通过PyEval_EvalFrameEx看到了Python虚拟机的整体框架.而这章开始,我们将了解Python虚拟机是如何完成对Python的一般表达式的执行,这 ...

  7. 山东理工大学第七届ACM校赛-G 飞花的传送门

    G - 飞花的传送门 飞花壕最近手头比较宽裕,所以想买两个传送门来代步(夏天太热,实在是懒得走路).平面上有N个传送门,飞花壕想要挑两个距离最远的传送门带回家(距离为欧几里得距离,即两点之间直线距离) ...

  8. NKOJ1236 a^b (数论定理的应用)

              a^b 对于任意两个正整数a,b(0<=a,b<10000)计算a^b各位数字的和的各位数字的和的各位数字的和的各位数字的和. Input 输入有多组数据,每组只有一行 ...

  9. CS231n笔记 Lecture 4 Introduction to Neural Networks

    这一讲主要介绍了神经网络,基本内容之前如果学习过Andrew的Machine learning应该也都有所了解了.不过这次听完这一讲后还是有了新的一些认识. 计算图 Computational gra ...

  10. 【Luogu】P3205合唱队(区间DP)

    题目链接 通过这题我发现我已经不会DP了 区间DP,f[i][j]是从左面转移来的,d[i][j]是从右面转移来的 然后DP方程是 ]) f[i][j]+=f[i+][j]; ][j]; f[i][j ...