2017 CCPC 湘潭邀请赛
2024-09-28 12:33:08
都tm快一年了我还没补这套题……再不补怕是要留给退役后乐
Problem A
把$n * (n + 1)$的矩阵补成$(n + 1) * (n + 1)$的,然后高斯消元。
Problem B
一看题解:费用流,于是这个题直接交给队友。
Problem C
又是高斯消元……
Problem D
直接输出即可。
#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) const int N = 1e2 + 10; int c[N][N], f[N][N];
int n, m, a, b; int main(){ while (~scanf("%d%d%d%d", &n, &m, &a, &b)){
rep(i, 1, n){
rep(j, 1, m) scanf("%1d", c[i] + j);
} rep(i, 1, n * a){
rep(j, 1, m * b){
int x = (i - 1) / a + 1;
int y = (j - 1) / b + 1;
printf("%d", c[x][y]);
}
putchar(10);
}
} return 0;
}
Problem E
占坑。
Problem F
首先可以肯定的是 $f_{0} + f_{1} + f_{2} + f_{3} = m^{3}$
那么计算出其中的$3$个就可以得到剩余的$1$个。
显然$f_{0}$和$f_{3}$是比较好求的。
所以$f_{1}$和$f_{2}$求出一个,问题就解决了。
大概是……$f_{2}$比较好求?
求$f_{3}$的时候记录一下有哪些三元组是符合这个条件的。
首先枚举两个数,把他们放在$(1, 2)$,$(1, 3)$,$(2, 3)$的位置,然后枚举剩下那个数可以是什么。
首先在$a[]$中没有出现的并且在$[1, m]$中的数肯定可以放,这个直接单独计算。
枚举在$a[]$中出现过的数,得到一个新的三元组,根据题意这个三元组要么计入$f_{2}$要么计入$f_{3}$。
那么看一下是否计入了$f_{3}$,如果不在就计入$f_{2}$
坑点:可能出现$a_{i} > m$的情况。
#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) typedef long long LL; const int N = 2e2 + 10;
const int M = 1e7 + 10; LL f0, f1, f2, f3;
bitset <M> c, d, f;
int n, nn, m;
int tot;
int a[N], b[N]; void calc_f0(){
rep(i, 1, n) b[i] = a[i];
sort(b + 1, b + n + 1); int cnt = unique(b + 1, b + n + 1) - b - 1;
tot = cnt;
rep(i, 1, n) a[i] = lower_bound(b + 1, b + cnt + 1, a[i]) - b;
f0 = 0ll + m - cnt;
f0 = 1ll * f0 * f0 * f0;
} void calc_f1(){
f1 = 1ll * m * m * m - f0 - f2 - f3;
} void calc_f2(){ f2 = 0;
d.reset();
f.reset(); rep(i, 1, n - 1){
rep(j, i + 1, n){
int x = a[i] * tot + a[j];
if (d[x]) continue;
d.set(x);
f2 += 0ll + m - tot;
rep(k, 1, tot){
int y = a[i] * tot * tot + a[j] * tot + k;
if (!c[y]) f.set(y);
}
}
} d.reset(); rep(i, 1, n - 1){
rep(j, i + 1, n){
int x = a[i] * tot + a[j];
if (d[x]) continue;
d.set(x);
f2 += 0ll + m - tot;
rep(k, 1, tot){
int y = k * tot * tot + a[i] * tot + a[j];
if (!c[y]) f.set(y);
}
}
} d.reset(); rep(i, 1, n - 1){
rep(j, i + 1, n){
int x = a[i] * tot + a[j];
if (d[x]) continue;
d.set(x);
f2 += 0ll + m - tot;
rep(k, 1, tot){
int y = a[i] * tot * tot + k * tot + a[j];
if (!c[y]) f.set(y);
}
}
} f2 += 0ll + f.count();
} void calc_f3(){
int cnt = 0;
c.reset();
rep(i, 1, n - 2){
rep(j, i + 1, n - 1){
rep(k, j + 1, n){
int x = a[i] * tot * tot + a[j] * tot + a[k];
c.set(x);
}
}
} f3 = c.count();
} int main(){ while (~scanf("%d%d", &n, &m)){
nn = n;
n = 0;
rep(i, 1, nn){
int x;
scanf("%d", &x);
if (x >= 1 && x <= m) a[++n] = x;
} calc_f0();
calc_f3();
calc_f2();
calc_f1(); printf("%lld %lld %lld %lld\n", f0, f1, f2, f3);
} return 0;
}
Problem G
Problem H
Problem I
Problem J
最新文章
- SQL Developer报错:Unable to find a Java Virtual Machine解决办法
- Linux有用命令
- [C++] 将 mp3 等音乐资源以资源形式嵌入 exe 文件中
- Spring-2-J Goblin Wars(SPOJ AMR11J)解题报告及测试数据
- java中静态代理跟动态代理之间的区别
- css实现鼠标经过导航文字偏位效果
- HTML5 canvas 合成属性
- 上传App时遇IDFA错误问题
- java基础知识2--String,StringBufffer,StringBuilder的区别
- 关于echarts、layer.js和jqGrid的知识点
- 开发JQuery插件(转)
- __name__ __doc__ __package__
- OpenStack实践系列①openstack简介及基础环境部署
- 【转】Emgu 图像阈值
- Jersey RESTful WebService框架学习(三)使用@QueryParam
- DXP 板层
- libcurl库的http get和http post使用【转】
- sar监控工具详解
- 【AGC012E】 Camel and Oases ST表+状压dp
- OpenCV学习(37) 人脸识别(2)
热门文章
- 《Cracking the Coding Interview》——第5章:位操作——题目4
- leetcode 【 Linked List Cycle 】 python 实现
- Python列表深浅复制详解
- cloud.cfg_for_centos
- 课时2:用python设计第一个游戏
- 课时21:函数:lambda表达式
- ocrosoft Contest1316 - 信奥编程之路~~~~~第三关 问题 E: IQ(iq)
- jquery.color.js
- Win10 WSL Ubuntu18.04 编译安装MySQL5.7
- npm &; npm config