day8 all file in the morning
This commit is contained in:
parent
0b26230ebd
commit
90add351d4
|
@ -0,0 +1 @@
|
||||||
|
7 13
|
|
@ -0,0 +1,2 @@
|
||||||
|
1
|
||||||
|
20
|
|
@ -0,0 +1,2 @@
|
||||||
|
19 37
|
||||||
|
37 41
|
|
@ -0,0 +1,3 @@
|
||||||
|
2
|
||||||
|
56
|
||||||
|
78
|
|
@ -0,0 +1,72 @@
|
||||||
|
#include<bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
const int MAX_T=1e3+5,MAX_N=1e6+5;
|
||||||
|
int a[MAX_T];
|
||||||
|
int n,maxn=INT_MIN;
|
||||||
|
bool is_unprime[MAX_N];
|
||||||
|
|
||||||
|
int readint();
|
||||||
|
void fill_unprime(bool isprime[],int num,int end);
|
||||||
|
|
||||||
|
int main(int argc,char *argv[]){
|
||||||
|
#ifdef OITEST
|
||||||
|
#define AS(c){if(!(c)){cerr<<"assert failed! :"<<#c<<endl;return 1;}}
|
||||||
|
AS(argc==3)
|
||||||
|
cout<<"TESTING:"<<endl<<argv[0]<<"\n"<<argv[1]<<"\n"<<argv[2]<<endl;
|
||||||
|
auto fin = freopen(argv[1],"r",stdin);
|
||||||
|
AS(fin!=NULL)
|
||||||
|
ifstream afile(argv[2]);
|
||||||
|
AS(afile.is_open()==true)
|
||||||
|
stringstream ss;
|
||||||
|
#define cout ss
|
||||||
|
#endif
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
|
||||||
|
n=readint();
|
||||||
|
for(int i=1;i<=n;i++){
|
||||||
|
a[i]=readint();
|
||||||
|
maxn=max(a[i],maxn);
|
||||||
|
}
|
||||||
|
for(int i=2;i<=(maxn/2)+1;i++){
|
||||||
|
if(is_unprime[i]==false){
|
||||||
|
fill_unprime(is_unprime,i,maxn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i=1;i<=n;i++){
|
||||||
|
for(int j=(a[i]/2);j<=a[i];j++){
|
||||||
|
if(!is_unprime[j]&&!is_unprime[a[i]-j]){
|
||||||
|
cout<<a[i]-j<<" "<<j<<"\n";
|
||||||
|
#ifdef OITEST
|
||||||
|
int cans1,cans2,myans1,myans2;
|
||||||
|
ss>>myans1>>myans2;
|
||||||
|
afile>>cans1>>cans2;
|
||||||
|
AS(cans1==myans1)
|
||||||
|
AS(cans2==myans2)
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fill_unprime(bool isprime[],int num,int end){
|
||||||
|
for(int i=num*2;i<=end;i+=num){
|
||||||
|
isprime[i]=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int readint(){
|
||||||
|
int x=0,w=1;
|
||||||
|
char ch=0;
|
||||||
|
while(!isdigit(ch)){
|
||||||
|
if(ch=='-')w=-1;
|
||||||
|
ch=getchar();
|
||||||
|
}
|
||||||
|
while(isdigit(ch)){
|
||||||
|
x=x*10+(ch-'0');
|
||||||
|
ch=getchar();
|
||||||
|
}
|
||||||
|
return x*w;
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
# 完美质数对
|
||||||
|
|
||||||
|
## 题目描述
|
||||||
|
|
||||||
|
一天小明和朋友比试猜数能力,他们共比试 $T$ 轮,每轮在屏幕上显示一个偶数 $n\ (n>2)$。
|
||||||
|
|
||||||
|
假设 $x,y$ 均为质数,$x \leq y$ 且 $x+y=n$,则称 $(x,y)$ 为偶数 $n$ 的一组质数对。如果哥德巴赫猜想为真,那么任意一个偶数 $n\ (n>2)$ 至少有一组质数对。在所有 $n$ 的质数对中 $x,y$ 两数最接近的质数对 $(x,y)$ 被叫作“完美质数对”。
|
||||||
|
|
||||||
|
请你帮小明快速地算出每个 $n$ 的“完美质数对”。
|
||||||
|
|
||||||
|
## 输入格式
|
||||||
|
|
||||||
|
第一行一个整数 $T$
|
||||||
|
|
||||||
|
接下来的 $T$ 行,每行一个整数 $n$
|
||||||
|
|
||||||
|
## 输出格式
|
||||||
|
|
||||||
|
共 $T$ 行,每行两个质数 $x,y\ (x<y)$
|
||||||
|
|
||||||
|
## 样例 #1
|
||||||
|
|
||||||
|
### 样例输入 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
1
|
||||||
|
20
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
7 13
|
||||||
|
```
|
||||||
|
|
||||||
|
## 样例 #2
|
||||||
|
|
||||||
|
### 样例输入 #2
|
||||||
|
|
||||||
|
```
|
||||||
|
2
|
||||||
|
56
|
||||||
|
78
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #2
|
||||||
|
|
||||||
|
```
|
||||||
|
19 37
|
||||||
|
37 41
|
||||||
|
```
|
||||||
|
|
||||||
|
## 提示
|
||||||
|
|
||||||
|
### 样例解释
|
||||||
|
|
||||||
|
对于样例 $1$,$n=20$,所有质数对有 $(3,17), (7,13)$,质数对中质数差分别为 $14,6$,因此 $(7,13)$ 是“完美质数对”
|
||||||
|
|
||||||
|
### 数据范围
|
||||||
|
|
||||||
|
本题采用捆绑测试,必须通过子任务中的所有测试点才能获得子任务对应分数。
|
||||||
|
|
||||||
|
子任务1(50pts): $1\le T\le 10, 2<n\le 1000$
|
||||||
|
|
||||||
|
子任务2(40pts): $1\le T\le 100, 2<n\le 10^4$
|
||||||
|
|
||||||
|
子任务3(10pts): $1\le T\le 1000, 2<n\le 10^6$
|
Binary file not shown.
|
@ -0,0 +1,165 @@
|
||||||
|
# 通关
|
||||||
|
|
||||||
|
## 题目描述
|
||||||
|
|
||||||
|
在你的面前是一个 $n$ 个珠子的关卡。这些珠子排成一行,编号 $1 \sim n$,已知初始从左到右第 $i$ 个珠子是编号 $p_i$.
|
||||||
|
|
||||||
|
由于你只有两只手,所以你每次可以拎出任意 $2$ 个珠子(不一定相邻)并将它们交换位置,你将要将这 $n$ 个珠子最终排成从左到右依次为 $1 \sim n$ 的顺序,这样才可以通关。
|
||||||
|
|
||||||
|
在你觉得这是个简单题的时候你突然在关卡的旁边读到了这样一句话:
|
||||||
|
|
||||||
|
> 特别注意:每个珠子有一个特定的颜色。由于同种颜色之间有强相互作用力,假如你某次拎出的 $2$ 个珠子是同一颜色,那么会相互吸引从而产生爆炸,**因此每次都必须交换 $2$ 个颜色不同的珠子。**
|
||||||
|
|
||||||
|
这下你突然对这个关卡开始感兴趣了,你打算着手来解决这个问题。关卡开发人员已经通过 $O(100000^{100000!})$ 的复杂度的算法提前计算出了最少步数,**你需要构造一组方案使得尽量接近这个最少步数,具体详见评分标准。**
|
||||||
|
|
||||||
|
## 输入格式
|
||||||
|
|
||||||
|
第一行两个数 $n,type=0/1$.
|
||||||
|
|
||||||
|
第二行 $n$ 个数,第 $i$ 个数为 $p_i$.
|
||||||
|
|
||||||
|
第三行 $n$ 个数,第 $i$ 个数表示从左到右**第 $i$ 个球的颜色编号**,设为 $c_i$.
|
||||||
|
|
||||||
|
## 输出格式
|
||||||
|
|
||||||
|
若 $type=0$,则**需要输出可行方案的最小步数**。否则,输出任意一个可行步数均可。但不管 $type$ 是多少,都需要保证这个步数不超过 $1 \times 10^6$。
|
||||||
|
|
||||||
|
接下来步数行,每行两个数 $x,y$ 以空格分隔,表示这次交换你要交换位于左数第 $x$ 个和第 $y$ 个的珠子。需要注意**必须要保证这些输出的行数等于第一行输出的数,否则 checker 会直接退出。**
|
||||||
|
|
||||||
|
**假如构造不出 $\leq 1 \times 10^6$ 次操作的方案,输出一个 $-1$ 即可。**
|
||||||
|
|
||||||
|
## 样例 #1
|
||||||
|
|
||||||
|
### 样例输入 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
4 0
|
||||||
|
2 1 4 3
|
||||||
|
2 1 3 4
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
2
|
||||||
|
1 2
|
||||||
|
3 4
|
||||||
|
```
|
||||||
|
|
||||||
|
## 样例 #2
|
||||||
|
|
||||||
|
### 样例输入 #2
|
||||||
|
|
||||||
|
```
|
||||||
|
6 1
|
||||||
|
3 5 4 6 1 2
|
||||||
|
4 5 1 1 1 6
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #2
|
||||||
|
|
||||||
|
```
|
||||||
|
5
|
||||||
|
1 2
|
||||||
|
1 5
|
||||||
|
2 3
|
||||||
|
4 6
|
||||||
|
2 4
|
||||||
|
```
|
||||||
|
|
||||||
|
## 样例 #3
|
||||||
|
|
||||||
|
### 样例输入 #3
|
||||||
|
|
||||||
|
```
|
||||||
|
23 1
|
||||||
|
14 8 23 19 6 9 5 22 20 15 1 11 21 13 18 12 16 4 17 2 3 7 10
|
||||||
|
3 5 5 1 5 5 2 2 5 1 2 5 3 1 1 1 4 3 5 2 5 5 4
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #3
|
||||||
|
|
||||||
|
```
|
||||||
|
35
|
||||||
|
11 1
|
||||||
|
20 2
|
||||||
|
11 21
|
||||||
|
21 3
|
||||||
|
11 3
|
||||||
|
18 4
|
||||||
|
7 5
|
||||||
|
4 7
|
||||||
|
7 6
|
||||||
|
4 6
|
||||||
|
4 22
|
||||||
|
22 7
|
||||||
|
4 7
|
||||||
|
20 8
|
||||||
|
4 22
|
||||||
|
22 9
|
||||||
|
4 9
|
||||||
|
23 10
|
||||||
|
12 11
|
||||||
|
16 12
|
||||||
|
14 13
|
||||||
|
3 16
|
||||||
|
16 14
|
||||||
|
3 14
|
||||||
|
4 23
|
||||||
|
23 15
|
||||||
|
4 15
|
||||||
|
17 16
|
||||||
|
19 17
|
||||||
|
4 23
|
||||||
|
23 18
|
||||||
|
4 18
|
||||||
|
23 19
|
||||||
|
22 20
|
||||||
|
23 21
|
||||||
|
```
|
||||||
|
|
||||||
|
## 样例 #4
|
||||||
|
|
||||||
|
### 样例输入 #4
|
||||||
|
|
||||||
|
```
|
||||||
|
见下发样例
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #4
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## 提示
|
||||||
|
|
||||||
|
本题使用 `checker` 来评判你的得分。本题下发文件中有一份可使用的 `checker.cpp` 和配套的 `testlib.h` 文件,想要使用 `checker` 你需要执行如下几步:
|
||||||
|
|
||||||
|
1. 将 `testlib.h` 与 `checker.cpp` 放至同一文件夹下,使用 `C++11` 编译 `checker.cpp` 获得可执行文件。
|
||||||
|
|
||||||
|
2. 将输入文件,答案文件和自己的输出文件放至同一文件夹下,使用命令行定位到该目录。
|
||||||
|
|
||||||
|
3. 使用语句 `./checker <input-file> <output-file> <answer-file>` 运行 `checker` 得到评判结果。
|
||||||
|
|
||||||
|
例如,设输入文件,答案文件和输出文件分别叫做 `pass.in,pass.out,mypass.out`
|
||||||
|
|
||||||
|
只需要运行语句:`./checker pass.in pass.out mypass.out`
|
||||||
|
|
||||||
|
4. 假如输出文件能够在该测试数据下得分,那么 `checker` 会回复 `ok`,否则会给出对应错误提示。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**需要注意你的代码不应依赖于 `checker`,为此 `checker.cpp` 文件做了模糊化处理。**
|
||||||
|
|
||||||
|
**本题使用 Subtask 评测,第 5 个子任务完全依赖第 1 个子任务。**
|
||||||
|
|
||||||
|
| 子任务分值 | 特殊限制 |
|
||||||
|
| :--------: | :-----------------------------: |
|
||||||
|
| $10$ | $n \leq 8$ |
|
||||||
|
| $10$ | $n \leq 10^5$,$c_i$ 是一个排列 |
|
||||||
|
| $20$ | $n \leq 10^5,type=1$ |
|
||||||
|
| $20$ | $n \leq 10^5,p_i=i\%n+1$ |
|
||||||
|
| $40$ | $n \leq 10^5$ |
|
||||||
|
|
||||||
|
对于全部数据,$1 \leq c_i \leq n$
|
Binary file not shown.
|
@ -0,0 +1,89 @@
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
const int N = 1e5 + 5;
|
||||||
|
string Inf, Ansf, Outf;
|
||||||
|
int n, tp, p[N], c[N], p1[N];
|
||||||
|
int pp[N], cc[N];
|
||||||
|
void perform(string Name, vector<pair<int, int> > moves) {
|
||||||
|
memcpy(pp, p, sizeof (p));
|
||||||
|
memcpy(cc, c, sizeof (c));
|
||||||
|
for (int i = 0; i < moves.size(); ++i) {
|
||||||
|
int x = moves[i].first, y = moves[i].second;
|
||||||
|
if (cc[pp[x]] == cc[pp[y]]) {
|
||||||
|
printf("Wrong Answer: Sorry, performance is invalid: ");
|
||||||
|
cout << Name << '\n';
|
||||||
|
assert(0);
|
||||||
|
} else swap(pp[x], pp[y]);
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= n; ++i) if (pp[i] != i) {
|
||||||
|
printf("Wrong Answer: Sorry, performance is invalid: ");
|
||||||
|
cout << Name << '\n';
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int main() {
|
||||||
|
cin >> Inf >> Ansf >> Outf;
|
||||||
|
FILE* In = fopen(Inf.c_str(), "r");
|
||||||
|
FILE* Ans = fopen(Ansf.c_str(), "r");
|
||||||
|
FILE* Out = fopen(Outf.c_str(), "r");
|
||||||
|
fscanf(In, "%d%d", &n, &tp);
|
||||||
|
if (n < 1 || n > 100000) {
|
||||||
|
puts("Invalid Input: N is invalid");
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= n; ++i) fscanf(In, "%d", &p[i]), p1[i] = p[i];
|
||||||
|
sort (p1 + 1, p1 + 1 + n);
|
||||||
|
for (int i = 1; i <= n; ++i) if (p1[i] != i) {
|
||||||
|
puts("Invalid Input: Sequence P is not a permutation");
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= n; ++i) {
|
||||||
|
fscanf(In, "%d", &c[p[i]]);
|
||||||
|
if (c[p[i]] < 1 || c[p[i]] > n) {
|
||||||
|
puts("Invalid Input: Sequence C is invalid");
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vector<pair<int, int> > J, P;
|
||||||
|
int siz = 0;
|
||||||
|
fscanf(Ans, "%d", &siz);
|
||||||
|
for (int i = 0; i < siz; ++i) {
|
||||||
|
int x, y;
|
||||||
|
fscanf(Ans, "%d%d", &x, &y);
|
||||||
|
J.push_back(make_pair(x, y));
|
||||||
|
}
|
||||||
|
int siz1 = 0;
|
||||||
|
cerr << "here " << siz1 << '\n';
|
||||||
|
fscanf(Out, "%d", &siz1);
|
||||||
|
if (siz == -1) {
|
||||||
|
if (siz1 != -1) {
|
||||||
|
puts("Wrong Answer: Sorry, Your answer is not correct");
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
else puts("Accepted: Your answer is correct");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (tp == 1) {
|
||||||
|
if (siz1 > 5000000) {
|
||||||
|
puts("Sorry, checker will TLE");
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
} else if (tp == 0) {
|
||||||
|
if (siz1 != siz) {
|
||||||
|
puts("Wrong Answer: Sorry, Your answer is not correct");
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
puts("Invalid Input: Type is invalid");
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < siz1; ++i) {
|
||||||
|
int x, y;
|
||||||
|
fscanf(Out, "%d%d", &x, &y);
|
||||||
|
P.push_back(make_pair(x, y));
|
||||||
|
}
|
||||||
|
perform(Ansf, J);
|
||||||
|
perform(Outf, P);
|
||||||
|
puts("Accepted: Your answer is correct");
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
2
|
||||||
|
1 2
|
||||||
|
3 4
|
|
@ -0,0 +1,3 @@
|
||||||
|
4 0
|
||||||
|
2 1 4 3
|
||||||
|
2 1 3 4
|
|
@ -0,0 +1,6 @@
|
||||||
|
5
|
||||||
|
1 2
|
||||||
|
1 5
|
||||||
|
2 3
|
||||||
|
4 6
|
||||||
|
2 4
|
|
@ -0,0 +1,3 @@
|
||||||
|
6 1
|
||||||
|
3 5 4 6 1 2
|
||||||
|
4 5 1 1 1 6
|
|
@ -0,0 +1,36 @@
|
||||||
|
35
|
||||||
|
11 1
|
||||||
|
20 2
|
||||||
|
11 21
|
||||||
|
21 3
|
||||||
|
11 3
|
||||||
|
18 4
|
||||||
|
7 5
|
||||||
|
4 7
|
||||||
|
7 6
|
||||||
|
4 6
|
||||||
|
4 22
|
||||||
|
22 7
|
||||||
|
4 7
|
||||||
|
20 8
|
||||||
|
4 22
|
||||||
|
22 9
|
||||||
|
4 9
|
||||||
|
23 10
|
||||||
|
12 11
|
||||||
|
16 12
|
||||||
|
14 13
|
||||||
|
3 16
|
||||||
|
16 14
|
||||||
|
3 14
|
||||||
|
4 23
|
||||||
|
23 15
|
||||||
|
4 15
|
||||||
|
17 16
|
||||||
|
19 17
|
||||||
|
4 23
|
||||||
|
23 18
|
||||||
|
4 18
|
||||||
|
23 19
|
||||||
|
22 20
|
||||||
|
23 21
|
|
@ -0,0 +1,3 @@
|
||||||
|
23 1
|
||||||
|
14 8 23 19 6 9 5 22 20 15 1 11 21 13 18 12 16 4 17 2 3 7 10
|
||||||
|
3 5 5 1 5 5 2 2 5 1 2 5 3 1 1 1 4 3 5 2 5 5 4
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,143 @@
|
||||||
|
# 线段树查询
|
||||||
|
|
||||||
|
## 题目背景
|
||||||
|
|
||||||
|
对于 $n^2$ 次对于所有区间的最值查询,居然有很多同学使用了线段树成功实现 $O(n^2logn)$ 复杂度,可见大家对线段树的喜爱之情溢于言表。
|
||||||
|
|
||||||
|
## 题目描述
|
||||||
|
|
||||||
|
sophie写了一棵线段树,建树和查询部分的代码如下:
|
||||||
|
```cpp
|
||||||
|
int tot = 0;
|
||||||
|
node* buildT(int l, int r){
|
||||||
|
node *p = new node;
|
||||||
|
p->l = l; p->r = r;
|
||||||
|
p->t = ++tot;//dfs序
|
||||||
|
if(l==r) return p;
|
||||||
|
|
||||||
|
int mid = (l + r)/2;
|
||||||
|
p->ls = buildT(l, mid);
|
||||||
|
p->rs = buildT(mid+1, r);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
void query(node* p, int l, int r){
|
||||||
|
if(p->l==l && p->r==r){
|
||||||
|
//到达终止结点
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mid = (p->l + p->r)/2;
|
||||||
|
if(r <= mid) query(p->ls, l, r);
|
||||||
|
else if(l >= mid+1) query(p->rs, l, r);
|
||||||
|
else{
|
||||||
|
query(p->ls, l, mid);
|
||||||
|
query(p->rs, mid+1, r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
对序列 $[1,n]$ 建完树之后,sophie在上面进行了所有 $n(n+1)/2$ 次区间查询 $[l,r]$,即 $[1,1],[1,2],...,[n,n]$(成功通过了 $n=500$ 的数据,获得12分!)
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
for(int l=1;l<=n;++l){
|
||||||
|
for(int r=l;r<=n;++r){
|
||||||
|
query(rt, l, r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
现在sophie想知道,对于线段树上的一个节点,其在多少次查询中是**终止节点**。
|
||||||
|
|
||||||
|
## 输入格式
|
||||||
|
|
||||||
|
第一行1个整数 $n,q$
|
||||||
|
|
||||||
|
接下来 $q$ 行,每行2个整数 $t$ 代表询问线段树上dfs序为 $t$ 的节点在多少次查询中是**终止节点**
|
||||||
|
|
||||||
|
## 输出格式
|
||||||
|
|
||||||
|
输出 $q$ 行,每行1个整数代表答案
|
||||||
|
|
||||||
|
## 样例 #1
|
||||||
|
|
||||||
|
### 样例输入 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
4 7
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
1
|
||||||
|
2
|
||||||
|
1
|
||||||
|
3
|
||||||
|
2
|
||||||
|
3
|
||||||
|
1
|
||||||
|
```
|
||||||
|
|
||||||
|
## 样例 #2
|
||||||
|
|
||||||
|
### 样例输入 #2
|
||||||
|
|
||||||
|
```
|
||||||
|
100 10
|
||||||
|
43
|
||||||
|
172
|
||||||
|
169
|
||||||
|
64
|
||||||
|
196
|
||||||
|
56
|
||||||
|
63
|
||||||
|
185
|
||||||
|
27
|
||||||
|
36
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #2
|
||||||
|
|
||||||
|
```
|
||||||
|
20
|
||||||
|
39
|
||||||
|
83
|
||||||
|
30
|
||||||
|
98
|
||||||
|
52
|
||||||
|
30
|
||||||
|
92
|
||||||
|
89
|
||||||
|
246
|
||||||
|
```
|
||||||
|
|
||||||
|
## 样例 #3
|
||||||
|
|
||||||
|
### 样例输入 #3
|
||||||
|
|
||||||
|
```
|
||||||
|
见下发样例
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #3
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## 提示
|
||||||
|
|
||||||
|
对于所有数据,$1\le n,q \le 10^6, 1\le t\le 2n-1$
|
||||||
|
|
||||||
|
子任务1(20分):$n,q\le 1000$
|
||||||
|
|
||||||
|
子任务2(20分):$n,q\le 10000$
|
||||||
|
|
||||||
|
子任务3(60分):无特殊限制
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
||||||
|
1
|
||||||
|
2
|
||||||
|
1
|
||||||
|
3
|
||||||
|
2
|
||||||
|
3
|
||||||
|
1
|
|
@ -0,0 +1,8 @@
|
||||||
|
4 7
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
|
@ -0,0 +1,10 @@
|
||||||
|
20
|
||||||
|
39
|
||||||
|
83
|
||||||
|
30
|
||||||
|
98
|
||||||
|
52
|
||||||
|
30
|
||||||
|
92
|
||||||
|
89
|
||||||
|
246
|
|
@ -0,0 +1,11 @@
|
||||||
|
100 10
|
||||||
|
43
|
||||||
|
172
|
||||||
|
169
|
||||||
|
64
|
||||||
|
196
|
||||||
|
56
|
||||||
|
63
|
||||||
|
185
|
||||||
|
27
|
||||||
|
36
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,100 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
U
|
||||||
|
DU
|
||||||
|
LRD
|
|
@ -0,0 +1,2 @@
|
||||||
|
3
|
||||||
|
1 3 2
|
|
@ -0,0 +1,100 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
U
|
||||||
|
UD
|
||||||
|
DLR
|
||||||
|
LRLR
|
||||||
|
LRLR
|
||||||
|
LRLR
|
||||||
|
LRLR
|
|
@ -0,0 +1,2 @@
|
||||||
|
4
|
||||||
|
6 7 5 4
|
|
@ -0,0 +1,100 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
U
|
||||||
|
LRD
|
||||||
|
LRLR
|
|
@ -0,0 +1,2 @@
|
||||||
|
4
|
||||||
|
1 2 2 3
|
|
@ -0,0 +1,100 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LR
|
||||||
|
LRLR
|
||||||
|
LRLRLR
|
|
@ -0,0 +1,2 @@
|
||||||
|
6
|
||||||
|
1 2 3 3 2 1
|
|
@ -0,0 +1 @@
|
||||||
|
-1
|
|
@ -0,0 +1,2 @@
|
||||||
|
6
|
||||||
|
1 2 1 1 2 1
|
|
@ -0,0 +1,128 @@
|
||||||
|
# 骨牌密铺
|
||||||
|
|
||||||
|
## 题目描述
|
||||||
|
|
||||||
|
有一个宽度为 $n$ 的栅栏,第 $i$ 列的高度为 $h[i]$。现在请你用 $1\times 2$ 和 $2\times 1$ 的骨牌对其进行密铺,输出方案。
|
||||||
|
|
||||||
|
例如 $n=3, h=[1,3,2]$,一个可行方案为:
|
||||||
|
```plain
|
||||||
|
U
|
||||||
|
DU
|
||||||
|
LRD
|
||||||
|
```
|
||||||
|
这里 `L/R` 表示一块水平骨牌的左/右部分,`U/D` 表示一块竖直骨牌的上/下部分;**其余部分输出空格 ` `(ASCII码32)**。
|
||||||
|
|
||||||
|
更多的例子参加样例。
|
||||||
|
|
||||||
|
## 输入格式
|
||||||
|
|
||||||
|
第一行 1 个整数 $n$
|
||||||
|
|
||||||
|
第二行 $n$ 个整数 $h[1,2,...,n]$,**保证 $0\le h[i]\le 100$**
|
||||||
|
|
||||||
|
## 输出格式
|
||||||
|
|
||||||
|
如果无解输出 `-1`;否则,**输出一个 $100$ 行 $n$ 列的字符矩阵,骨牌用 `L/R/U/D` 表示,其余用空格 ` ` 表示**。
|
||||||
|
|
||||||
|
* 注意严格按照输出格式进行输出,合法方案必须要输出 100 行
|
||||||
|
|
||||||
|
## 样例 #1
|
||||||
|
|
||||||
|
### 样例输入 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
3
|
||||||
|
1 3 2
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
U
|
||||||
|
DU
|
||||||
|
LRD
|
||||||
|
```
|
||||||
|
|
||||||
|
## 样例 #2
|
||||||
|
|
||||||
|
### 样例输入 #2
|
||||||
|
|
||||||
|
```
|
||||||
|
4
|
||||||
|
6 7 5 4
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #2
|
||||||
|
|
||||||
|
```
|
||||||
|
U
|
||||||
|
UD
|
||||||
|
DUU
|
||||||
|
UDDU
|
||||||
|
DUUD
|
||||||
|
UDDU
|
||||||
|
DLRD
|
||||||
|
```
|
||||||
|
|
||||||
|
## 样例 #3
|
||||||
|
|
||||||
|
### 样例输入 #3
|
||||||
|
|
||||||
|
```
|
||||||
|
4
|
||||||
|
1 2 2 3
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #3
|
||||||
|
|
||||||
|
```
|
||||||
|
U
|
||||||
|
LRD
|
||||||
|
LRLR
|
||||||
|
```
|
||||||
|
|
||||||
|
## 样例 #4
|
||||||
|
|
||||||
|
### 样例输入 #4
|
||||||
|
|
||||||
|
```
|
||||||
|
6
|
||||||
|
1 2 3 3 2 1
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #4
|
||||||
|
|
||||||
|
```
|
||||||
|
LR
|
||||||
|
LRLR
|
||||||
|
LRLRLR
|
||||||
|
```
|
||||||
|
|
||||||
|
## 样例 #5
|
||||||
|
|
||||||
|
### 样例输入 #5
|
||||||
|
|
||||||
|
```
|
||||||
|
6
|
||||||
|
1 2 1 1 2 1
|
||||||
|
```
|
||||||
|
|
||||||
|
### 样例输出 #5
|
||||||
|
|
||||||
|
```
|
||||||
|
-1
|
||||||
|
```
|
||||||
|
|
||||||
|
## 提示
|
||||||
|
|
||||||
|
**注意,为了样例可读性,样例输出忽略了空行**
|
||||||
|
|
||||||
|
对于 27% 的数据,$n,h[i]\le 3$
|
||||||
|
|
||||||
|
对于 49% 的数据,$n,h[i]\le 5$
|
||||||
|
|
||||||
|
对于另 17% 的数据,$n\le 1000, h[i]\le 2$
|
||||||
|
|
||||||
|
对于另 17% 的数据,$n\le 1000, h[i]\le 10$
|
||||||
|
|
||||||
|
对于所有数据,$1\le n\le 1000, 0\le h[i]\le 100$
|
Binary file not shown.
12
xmake.lua
12
xmake.lua
|
@ -2,6 +2,7 @@ add_rules("mode.release","mode.debug")
|
||||||
if is_mode("debug")then
|
if is_mode("debug")then
|
||||||
add_defines("OIPRINT")
|
add_defines("OIPRINT")
|
||||||
end
|
end
|
||||||
|
set_warnings("all")
|
||||||
|
|
||||||
target("st_raw")
|
target("st_raw")
|
||||||
set_kind("binary")
|
set_kind("binary")
|
||||||
|
@ -69,6 +70,13 @@ target("P3372")
|
||||||
add_files("./day7/P3372/*.cpp")
|
add_files("./day7/P3372/*.cpp")
|
||||||
for v=1,1 do
|
for v=1,1 do
|
||||||
local s=tostring(v)
|
local s=tostring(v)
|
||||||
add_tests(s,{files="./day7/P3372/*.cpp",runargs={s..".in",s..".ans",defines="OITEST"}})
|
add_tests(s,{files="./day7/P3372/*.cpp",runargs={s..".in",s..".ans"},defines="OITEST"})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
target("T493931")
|
||||||
|
set_rundir("./day8/T493931")
|
||||||
|
add_files("./day8/T493931/*.cpp")
|
||||||
|
for v=1,2 do
|
||||||
|
local s = tostring(v)
|
||||||
|
add_tests(s,{files="./day8/T493931/*.cpp",runargs={s..".in",s..".ans"},defines="OITEST"})
|
||||||
|
end
|
Loading…
Reference in New Issue