本文的目的是介绍Tenka1ComputerContestC-Align的详细情况,我们将通过专业的研究、有关数据的分析等多种方式,同时也不会遗漏关于./node_modules/rc-align/e
本文的目的是介绍Tenka 1 Computer Contest C-Align的详细情况,我们将通过专业的研究、有关数据的分析等多种方式,同时也不会遗漏关于./node_modules/rc-align/es/Align.js中的错误、2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest)、2018-2019 ACM-ICPC Pacific Northwest Regional Contest C Contest Setting(DP)、716 css flex布局:flex-flow,flex-direction,flex-wrap,justify-content,align-items,align-content,flex,ord的知识。
本文目录一览:- Tenka 1 Computer Contest C-Align
- ./node_modules/rc-align/es/Align.js中的错误
- 2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest)
- 2018-2019 ACM-ICPC Pacific Northwest Regional Contest C Contest Setting(DP)
- 716 css flex布局:flex-flow,flex-direction,flex-wrap,justify-content,align-items,align-content,flex,ord
Tenka 1 Computer Contest C-Align
C - Align
Time limit : 2sec / Memory limit : 1024MB
Score : 400 points
Problem Statement
You are given N integers; the i-th of them is Ai. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.
Constraints
- 2≤N≤105
- 1≤Ai≤109
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
A1
:
AN
Output
Print the maximum possible sum of the absolute differences between the adjacent elements after arranging the given integers in a row in any order you like.
Sample Input 1
5
6
8
1
2
3
Sample Output 1
21
When the integers are arranged as 3,8,1,6,2, the sum of the absolute differences between the adjacent elements is |3−8|+|8−1|+|1−6|+|6−2|=21. This is the maximum possible sum.
Sample Input 2
6
3
1
4
1
5
9
Sample Output 2
25
Sample Input 3
3
5
5
1
Sample Output 3
8
题解:分奇数和偶数讨论。当为奇数时,一定是中间的两个数在左右边(两种情况)使得结果最大。偶数同理,更好枚举,只有一种情况。


#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#define ll long long
//#define local
using namespace std;
const int MOD = 1e9+7;
const int inf = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int maxn = 1e5+10;
int main() {
#ifdef local
if(freopen("/Users/Andrew/Desktop/data.txt", "r", stdin) == NULL) printf("can''t open this file!\n");
#endif
int n;
int a[maxn];
ll mx = 0;
ll sum[maxn];
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d", a+i);
}
sort(a, a+n);
for (int i = 0; i < n; ++i) {
if (!i) sum[i] = a[i];
if (i) sum[i] = sum[i-1]+a[i];
}
if (n&1) {
if (n == 3) {
mx = max(abs(2*a[2]-a[1]-a[0]), abs(2*a[0]-a[1]-a[2])); //当n=3时,特殊讨论一下
} else {
//如果是选择靠左边的两个数作为两个端点,那么他们一定是小于它们相邻的数的。
//同理,如果是选择靠左边的两个数作为两个端点,那么他们一定是大于它们相邻的数的。
//将需要算两次的数*2
mx = max(abs(2*(sum[n-1]-sum[n/2])-2*(sum[n/2-2])-(a[n/2]+a[n/2-1])), abs(2*(sum[n-1]-sum[n/2+1])-2*(sum[n/2-1])+(a[n/2]+a[n/2+1])));
}
} else {
mx = abs(2*(sum[n-1]-sum[n/2])-2*(sum[n/2-2])+abs(a[n/2]-a[n/2-1]));
}
printf("%lld\n", mx);
#ifdef local
fclose(stdin);
#endif
return 0;
}
./node_modules/rc-align/es/Align.js中的错误
如何解决./node_modules/rc-align/es/Align.js中的错误?
直到今天为止,项目都运行良好,不断出现此错误
ERROR in ./node_modules/rc-align/es/Align.js
Module not found: Error: Can''t resolve ''rc-util/es/Dom/isVisible'' in ''/Users/faizan/Simplus/UniLever/visum-web/node_modules/rc-align/es''
我尝试重新安装node_modules,但仍然无济于事,我似乎也找不到任何解决方案。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest)
2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest)
Problem A. Manhattan
solved by RDC 32 min 1Y
题意 给一网格图,找出欧几里得距离为 d 的两点,最大化最短路。
第一回合
三分搜索,第一个点的坐标 $(x,0)(0\leq x<1)$,确定第一个点后,对第二个点的横坐标或者纵坐标进行枚举计算答案。
第二回合
设最优解两点之间,横坐标差绝对值为 $dx$ 纵坐标差绝对值为 $dy$,分类讨论。
- 当 $dx$ 为整数时,枚举 $dx$,有 $dy=\sqrt{d^2-dx^2}$。
- 当 $dy$ 为整数时,枚举 $dy$。
- 否则,猜测答案为 $\sqrt{2}d$,两点斜率绝对值为 1。(距离为 $d$ 的两点曼哈顿距离最大值为 $\sqrt{2}d$)
第三回合
- 注意到,若 $min(dx,dy)\geq 1$ 或者 $dx,dy$ 皆不为整数,两点间最短路即曼哈顿距离。
- 当两点间最短距离不是曼哈顿距离时,$0 \leq min(dx,dy)<1$,且 $dx,dy$ 中存在正整数。
Problem C. Clique Coloring
solved by RDC 112 min 1Y
题意 求极小的 m,使得可以选出大小分别为 $a_1,a_2,...,a_n$ 的子集,使得两两交大小小于等于 1.
做法
- 注意到任意两个集合的交,小于等于 1.
- 元素按,是否归属于 $1,2,...,n$ 号集合,可以划分成 $2^n$ 个等价类,编号分别为 $0$~$2^n-1$
- DFS 枚举编号 $bitcount()$ 大于 1 的等价类中是否有元素,剪掉一些 invalid 的枚举(若 $bitcount(x&y) \geq 2$,那么第 x 个等价类,第 y 个等价类,不可同时有元素)。
- 合法的枚举方案很少 $(<1e5)$,对每种方案统计答案即可。
Problem B. Dictionary
upsolved by RDC,sdcgvhgj,F0_0H
题意 给 n 个串,字符集为小写字母,替换 ''?'',使字典序单增。
做法1 考虑 DP
- $f[l][r][p][c]$ 表示考虑第 l 个串到第 r 个串的 p ~ 20 位, 使得它们字典序单增,且 $s[x] [p]=c(l \leq x \leq r)$ 的方案数。
- $g[l][r][p][c]$ 表示考虑第 l 个串到第 r 个串的 p ~ 20 位, 使得它们字典序单增,且 $s[l] [p]=c$ 的方案数。
- $g[21][i][i][''\0'']=f[21][i][i][''\0'']=1(1\leq i\leq n)$
- $f[l][r][p][c]=\sum_{ch}g[l][r][p+1][c]*[condition]$,其中 $[condition]$ 表示 $s[x][p](l\leq x\leq r)$ 能否全为字符 $c$.
- $g[l][r][p][c]=\sum_{ch>c}\sum_{mid}f[l][mid][p][c]*((mid+1<=r)?g[mid+1][r][p][ch]:1)$
- 对 $g[l][r][p][]$ 做后缀和,优化。 code
做法2 对上述状态转移的简化
- $f[l][r][p][c]$表示考虑第 l 个串到第 r 个串的 p ~ 20 位, 使得它们字典序单增,且 $s[x] [p]\leq c(l \leq x \leq r)$ 的方案数。
- $f[l][r][p][c]=\sum_{ch<c}\sum_{mid}f[l][mid][p][ch]f[mid+1][r][p+1][''z''][condition]$,其中$[condition]$表示$s[x][p](mid+1\leq x\leq r)$能否全为字符$c+1$ code
Problem D. Dense Amidakuji
upsolved by F0_0H
题意 排骨龙沿着竹竿往下爬,输出会从哪个竹竿落下。
做法
考虑两个如下事实:
- 对于每条横边,定会被经过两次,一次从左往右,一次从右往左
- 每删除一条横边,相当于交换该横边左右两次经过的状态
所以只需要考虑每条横边原始被经过的标号,交换一下即可(从上到下考虑) code
Problem G. Snake
upsolved by sdcgvhgj
题意 给一条折线段$P_1P_2,.....P_n$,问能否穿过一个洞。
口胡 by rdc
- 能穿过洞,等价于折线段在任意位置都能被直线划分成两段。
- 若在位置 $Q$ 能被划分成两段,那么必存在 $1\leq i \leq n$,使得 $QP_i$ 能把折线段划分成两段。
- 枚举点 $P_i$,更新点集 ${Q|P_iQ 能划分折线段}$。
- 有解,等价于,$\cup_{i=1}^{n} {Q|P_iQ 能划分折线段} = 折线段上点组成点集$。
Problem J. Hyperrectangle
题意 输入 $d$ 维长方体,求 $x_1+x_2+..+x_d\leq s$ 体积。
2018-2019 ACM-ICPC Pacific Northwest Regional Contest C Contest Setting(DP)
比赛链接:Contest Setting C题
题意:$n$道题目,每道题目难度为$ai$,选择$k$道难度不同的题目,有多少种选择方案。$1<=k<=n<=1000,1<=ai<=10^9$
题解:问题转化一下(map,离散化均可):m种难度,每种难度有bi道题目,每次从m种中选择k种,把对应的题目数量相乘,求总和。
列出$dp[i][j]$:表示前j个物品以j结尾选择i个的方案数;$sum[i][j]$:表示从1-j分别作为结尾选择i个的方案数总和。
$dp[i][j]=b[j]*sum[i-1][j-1]$
$sum[i][j]=sum[i][j-1]+dp[i][j]$


1 #include <map>
2 #include <cstdio>
3 #include <vector>
4 #include <cstring>
5 #include <iostream>
6 #include <algorithm>
7 using namespace std;
8
9 const int N=1e3+10;
10 typedef long long ll;
11 const ll mod=998244353;
12 map <ll,ll> m;
13 vector <ll> v;
14 ll b[N],dp[N][N],sum[N][N];
15
16 int main(){
17 int n,k;
18 ll x;
19 scanf("%d%d",&n,&k);
20 for(int i=1;i<=n;i++){
21 scanf("%lld",&x);
22 if(m[x]==0) v.push_back(x);
23 m[x]++;
24 }
25 n=v.size();
26 for(int i=1;i<=n;i++) b[i]=m[v[i-1]];
27 for(int i=1;i<=n;i++) dp[1][i]=b[i]%mod,sum[1][i]=(dp[1][i]+sum[1][i-1])%mod;
28 for(int i=2;i<=k;i++){
29 for(int j=1;j<=n;j++){
30 dp[i][j]=(b[j]*sum[i-1][j-1])%mod;
31 sum[i][j]=(dp[i][j]+sum[i][j-1])%mod;
32 }
33 }
34 printf("%lld\n",sum[k][n]);
35 return 0;
36 }
716 css flex布局:flex-flow,flex-direction,flex-wrap,justify-content,align-items,align-content,flex,ord
认识flex布局
flex布局模型
flex相关的属性
Flex-direction
Justify-content
align-items
flex-wrap、flex-flow
align-content
order
align-self
flex-grow
flex-shrink
flex-basis
flex
09_flex布局的使用01.html
<!DOCTYPE html>
<html lang="en">
<head>
<Meta charset="UTF-8" />
<Meta name="viewport" content="width=device-width, initial-scale=1.0" />
<Meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<style>
.Box {
width: 550px;
height: 400px;
background-color: pink;
margin: 0 auto;
/*
1.开启flex布局:
flex: 块级元素
inline-flex: 行内元素
*/
display: flex;
/* 2.flex-direction: 决定主轴的方向 */
/* row: 主轴从左到右 */
/* row-reverse: 主轴从右到左 */
/* column: 主轴从上到下 */
/* column-reverse: 主轴从下到上 */
/* flex-direction: column-reverse; */
/* 3.justify-content: 决定flex items主轴的对齐方式 */
/* justify-content: space-around; */
/* 4.align-items: 绝定flex items在交叉轴的对齐方式 */
/* align-items: baseline; */
/* 5.结论: 默认情况下, 所有的flex items都会在同一行显示 */
/* flex-wrap: Nowrap */
/* Nowrap: 不换行 */
/* flex-wrap: wrap-reverse; */
/* 6.flex-flow: 缩写属性 -> flex-direction || flex-wrap */
flex-flow: row wrap;
justify-content: space-evenly;
/* 7.align-content: 决定多行的flex items在交叉轴上的对齐方式 */
align-content: space-around;
}
.item {
width: 100px;
height: 100px;
color: #fff;
text-align: center;
}
.item1 {
background-color: #f66;
/* height: 60px; */
/* font-size: 50px; */
}
.item2 {
background-color: yellowgreen;
/* height: 150px; */
}
.item3 {
background-color: skyblue;
/* height: 120px; */
}
</style>
</head>
<body>
<div/tag/Box/" target="_blank">Box">
<div>item1</div>
<div>item2</div>
<div>item3</div>
<div>item4</div>
<div>item5</div>
<div>item6</div>
<div>item7</div>
<div>item8</div>
<div>item9</div>
</div>
<strong>strong元素</strong>
</body>
</html>
10_flex布局的使用02.html
<!DOCTYPE html>
<html lang="en">
<head>
<Meta charset="UTF-8" />
<Meta name="viewport" content="width=device-width, initial-scale=1.0" />
<Meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<style>
.Box {
width: 550px;
height: 400px;
background-color: orange;
margin: 0 auto;
/* 1.开启flex布局*/
display: flex;
/* align-items: center; */
/* flex-wrap: wrap; */
}
/*
750px - 550px = 200px
200 / 3 = 66.66666px
250 - 66 =
*/
/*
200 / 5 = 40
*/
.item {
width: 100px;
height: 100px;
color: #fff;
text-align: center;
/* 1: flex-grow */
flex: 1;
}
.item1 {
background-color: #f66;
/* order: 10; */
/* flex-grow: .2; */
/* flex-shrink: .2; */
/* flex-basis: 200px; */
}
.item2 {
background-color: #0f0;
/* height: 150px; */
/* order: 6; */
/* flex-grow: .2; */
/* flex-shrink: .2; */
}
.item3 {
background-color: #00f;
/* align-self: flex-end; */
/* order: 100; */
/* flex-grow: .3; */
/* flex-shrink: .2; */
}
</style>
</head>
<body>
<div/tag/Box/" target="_blank">Box">
<div>item1</div>
<div>item2</div>
<div>item3</div>
</div>
<strong>strong元素</strong>
</body>
</html>
今天关于Tenka 1 Computer Contest C-Align的讲解已经结束,谢谢您的阅读,如果想了解更多关于./node_modules/rc-align/es/Align.js中的错误、2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest)、2018-2019 ACM-ICPC Pacific Northwest Regional Contest C Contest Setting(DP)、716 css flex布局:flex-flow,flex-direction,flex-wrap,justify-content,align-items,align-content,flex,ord的相关知识,请在本站搜索。
本文标签: