update
This commit is contained in:
parent
1f0738cd58
commit
976ebb2b03
16
.vscode/launch.json
vendored
Normal file
16
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
// 使用 IntelliSense 了解相关属性。
|
||||||
|
// 悬停以查看现有属性的描述。
|
||||||
|
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Debug",
|
||||||
|
"program": "${workspaceFolder}/<executable file>",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,72 +0,0 @@
|
|||||||
# 区间最值求和
|
|
||||||
|
|
||||||
## 题目描述
|
|
||||||
|
|
||||||
给一个长度 $n$ 的序列 $a$,求:
|
|
||||||
$$
|
|
||||||
\sum_{l=1}^n\sum_{r=l}^n max(a[l...r])
|
|
||||||
$$
|
|
||||||
|
|
||||||
## 输入格式
|
|
||||||
|
|
||||||
第一行1个整数 $n$
|
|
||||||
|
|
||||||
第二行 $n$ 个整数 $a[1,2,...,n]$
|
|
||||||
|
|
||||||
## 输出格式
|
|
||||||
|
|
||||||
输出1个整数代表答案
|
|
||||||
|
|
||||||
## 样例 #1
|
|
||||||
|
|
||||||
### 样例输入 #1
|
|
||||||
|
|
||||||
```
|
|
||||||
4
|
|
||||||
2 1 3 4
|
|
||||||
```
|
|
||||||
|
|
||||||
### 样例输出 #1
|
|
||||||
|
|
||||||
```
|
|
||||||
30
|
|
||||||
```
|
|
||||||
|
|
||||||
## 样例 #2
|
|
||||||
|
|
||||||
### 样例输入 #2
|
|
||||||
|
|
||||||
```
|
|
||||||
5
|
|
||||||
4 5 7 2 4
|
|
||||||
```
|
|
||||||
|
|
||||||
### 样例输出 #2
|
|
||||||
|
|
||||||
```
|
|
||||||
87
|
|
||||||
```
|
|
||||||
|
|
||||||
## 样例 #3
|
|
||||||
|
|
||||||
### 样例输入 #3
|
|
||||||
|
|
||||||
```
|
|
||||||
见下发样例
|
|
||||||
```
|
|
||||||
|
|
||||||
### 样例输出 #3
|
|
||||||
|
|
||||||
```
|
|
||||||
见下发样例
|
|
||||||
```
|
|
||||||
|
|
||||||
## 提示
|
|
||||||
|
|
||||||
对于所有数据,$1\le n,a[i]\le 10^6$
|
|
||||||
|
|
||||||
subtask1(20pts):$n \le 5000$
|
|
||||||
|
|
||||||
subtask2(20pts):$a[i]\le 50$
|
|
||||||
|
|
||||||
subtask4(60pts):无特殊限制
|
|
34
day2/U111091/U111091.cpp
Normal file
34
day2/U111091/U111091.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include<bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
const int MAX_N = 5'0000+5;
|
||||||
|
int times;
|
||||||
|
int n,k,m;
|
||||||
|
int x[MAX_N];
|
||||||
|
int l[MAX_N];
|
||||||
|
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
cin.sync_with_stdio(false);
|
||||||
|
cin.tie(0);
|
||||||
|
|
||||||
|
cin>>times;
|
||||||
|
for(int t=1;t<=times;t++){
|
||||||
|
cin>>n>>k>>m;
|
||||||
|
for (int i=1; i<=n; i++) {
|
||||||
|
cin>>x[i];
|
||||||
|
}
|
||||||
|
string s;
|
||||||
|
cin>>s;
|
||||||
|
assert(s.size()==n-1);
|
||||||
|
for(int i=0;i<=s.size();i++){
|
||||||
|
if (s[i]=='0') {
|
||||||
|
l[i+1]=0;
|
||||||
|
}else {
|
||||||
|
l[i+1]=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
107
day2/U111091/U111091.md
Normal file
107
day2/U111091/U111091.md
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
# 区间2段覆盖
|
||||||
|
|
||||||
|
## 题目描述
|
||||||
|
|
||||||
|
有 $n$ 个村庄坐落在数轴上,坐标为 $x[1...n]$。村庄之间有 $n-1$ 条道路,其中有些道路是土路,有些是高速公路。具体地,第 $i$ 个村庄和第 $i+1$ 个村庄之间只有一条道路,要么是土路、要么是高速公路,并且输入会告诉所有 $n-1$ 条道路的种类。
|
||||||
|
|
||||||
|
现在有 $k(k\le 2)$ 个铺路计划,每个铺路计划可以在数轴上 **任意选择一段长度$\le m$** 的区间 $[l,r]$,将其中间全部变成高速公路。注意区间端点可以任意选择,可以选在村庄处、村庄之间,甚至可以是小数。
|
||||||
|
|
||||||
|
请问该如何铺路,使得从 $x[1]$ 走到 $x[n]$ 路径上的土路总长度最小。
|
||||||
|
|
||||||
|
## 输入格式
|
||||||
|
|
||||||
|
第一行1个整数 $T$,代表有 $T$ 组数据
|
||||||
|
|
||||||
|
每组数据第一行 3 个整数 $n,k,m$
|
||||||
|
|
||||||
|
第二行 $n$ 个整数 $x[1,2,...,n]$,保证 $x[1]=0, x[i-1]\le x[i]$
|
||||||
|
|
||||||
|
第三行 1 个长度 $n-1$ 的 `01`字符串,代表 $n-1$ 条路的种类,`0` 代表高速公路,`1` 代表土路。
|
||||||
|
|
||||||
|
## 输出格式
|
||||||
|
|
||||||
|
输出 $T$ 行,对于每组数据输出1个整数代表答案
|
||||||
|
|
||||||
|
## 样例 #1
|
||||||
|
|
||||||
|
### 样例输入 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
5
|
||||||
|
3 2 13
|
||||||
|
0 6 80
|
||||||
|
11
|
||||||
|
7 2 11
|
||||||
|
0 50 80 83 86 97 97
|
||||||
|
111011
|
||||||
|
2 2 43
|
||||||
|
0 83
|
||||||
|
1
|
||||||
|
9 2 47
|
||||||
|
0 26 34 40 71 75 79 98 99
|
||||||
|
11111101
|
||||||
|
10 2 36
|
||||||
|
0 14 28 29 30 37 55 64 65 81
|
||||||
|
011101000
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
54
|
||||||
|
72
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
```
|
||||||
|
|
||||||
|
## 样例 #2
|
||||||
|
|
||||||
|
### 样例输入 #2
|
||||||
|
|
||||||
|
```
|
||||||
|
2
|
||||||
|
5 2 3
|
||||||
|
0 1 2 3 5
|
||||||
|
1011
|
||||||
|
4 2 3
|
||||||
|
0 1 5 6
|
||||||
|
111
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #2
|
||||||
|
|
||||||
|
```
|
||||||
|
0
|
||||||
|
0
|
||||||
|
```
|
||||||
|
|
||||||
|
## 样例 #3
|
||||||
|
|
||||||
|
### 样例输入 #3
|
||||||
|
|
||||||
|
```
|
||||||
|
见下发样例
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #3
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## 提示
|
||||||
|
|
||||||
|
对于100%的数据,$1\le n\le 50000, 0\le m,x[i]\le 10^9,1\le T\le 100$
|
||||||
|
|
||||||
|
subtask1(20pts):$n\le 500,m,x[i]\le 10^5,k=1$
|
||||||
|
|
||||||
|
subtask2(20pts):$n\le 500,m,x[i]\le 10^5,k=2$
|
||||||
|
|
||||||
|
subtask3(20pts):$n\le 50000,m,x[i]\le 10^9,k=1$
|
||||||
|
|
||||||
|
subtask4(40pts):$n\le 50000,m,x[i]\le 10^9,k=2$
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**【注意】请使用快速的读入方式**
|
BIN
day2/U458258/U458258
Executable file
BIN
day2/U458258/U458258
Executable file
Binary file not shown.
@ -1,11 +1,47 @@
|
|||||||
#include <bits/stdc++.h>
|
#include <bits/stdc++.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
#define int long long
|
||||||
|
|
||||||
|
const int MOD = 1e9+7;
|
||||||
|
const int MAX_N = 1e5+5;
|
||||||
|
int a[MAX_N];
|
||||||
|
int prefix_a[MAX_N];
|
||||||
int times;
|
int times;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
signed main(){
|
||||||
|
cin.sync_with_stdio(false);
|
||||||
|
cin.tie(0);
|
||||||
|
|
||||||
int main(){
|
|
||||||
cin>>times;
|
cin>>times;
|
||||||
for (int i=1; i<=times; i++) {
|
for (int t=1; t<=times; t++) {
|
||||||
|
int cnt = 0;
|
||||||
|
prefix_a[0] = 0;
|
||||||
|
cin>>n;
|
||||||
|
for (int i=1; i<=n; i++) {
|
||||||
|
cin>>a[i];
|
||||||
|
prefix_a[i] = (a[i]+prefix_a[i-1])%MOD;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
cout<<"\nprefix_a:\n";
|
||||||
|
for (int i=1; i<=n; i++) {
|
||||||
|
cout<<prefix_a[i]<<" ";
|
||||||
|
}
|
||||||
|
cout<<"\n";
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (int l=1; l<=n; l++) {
|
||||||
|
for (int r=l; r<=n; r++) {
|
||||||
|
cnt=(
|
||||||
|
(
|
||||||
|
(prefix_a[r]-prefix_a[l-1])
|
||||||
|
/
|
||||||
|
(r-l+1)
|
||||||
|
)
|
||||||
|
+cnt
|
||||||
|
)%MOD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<cnt<<"\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
60
day2/U458258/U458258.md
Normal file
60
day2/U458258/U458258.md
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# 平均数之和
|
||||||
|
|
||||||
|
## 题目描述
|
||||||
|
|
||||||
|
对于一个长度为 $n$ 的数组,有 $\frac{n \times (n + 1)}{2}$ 个连续子区间。对于子区间 $a[l\sim r]$,其平均值为
|
||||||
|
$$
|
||||||
|
\frac{a[l]+...+a[r]}{r-l+1}
|
||||||
|
$$
|
||||||
|
|
||||||
|
求数组的所有子区间的平均数之和,对 $P=10^9+7$ 取模。
|
||||||
|
|
||||||
|
* 模意义下的除法:如果需要计算 $a/b \pmod P$,可以使用 $a\times b^{P-2} \pmod P$ 实现
|
||||||
|
|
||||||
|
## 输入格式
|
||||||
|
|
||||||
|
第一行1个整数 $t$,代表数据组数
|
||||||
|
|
||||||
|
每组数据第1行一个正整数 $n$,表示数组长度
|
||||||
|
|
||||||
|
每组数据第2行 $n$ 个正整数 $a[1\sim n]$
|
||||||
|
|
||||||
|
## 输出格式
|
||||||
|
|
||||||
|
输出 $t$ 行,每行1个整数代表答案
|
||||||
|
|
||||||
|
## 样例 #1
|
||||||
|
|
||||||
|
### 样例输入 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
5
|
||||||
|
7
|
||||||
|
1 4 3 9 3 6 10
|
||||||
|
4
|
||||||
|
4 9 2 9
|
||||||
|
4
|
||||||
|
9 9 1 7
|
||||||
|
6
|
||||||
|
8 9 1 6 5 7
|
||||||
|
10
|
||||||
|
5 6 10 5 7 9 2 4 3 2
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
792857292
|
||||||
|
166666727
|
||||||
|
500000066
|
||||||
|
633333457
|
||||||
|
564286026
|
||||||
|
```
|
||||||
|
|
||||||
|
## 提示
|
||||||
|
|
||||||
|
对于 30% 的测试点,$1 \leq n \leq 100$
|
||||||
|
|
||||||
|
对于 70% 的测试点,$1 \leq n \leq 5000$
|
||||||
|
|
||||||
|
对于 100% 的测试点,$1\le t\le 10, 1 \leq n \leq 10^5, 1 \leq a[i] \leq 100$
|
Loading…
Reference in New Issue
Block a user