P7117 Mivik 卷积 题解
:::info[提示 1]{close} 这个题目里的式子不像是人类能读懂的东西,我们怎么读懂它? ::: :::success[答案 1]{close} 我们首先改写卷积的方法。容易得到,
意思很明白。
| 显然, |
|---|
| :::info[提示 2]{close} |
| 感觉还是不能直观地考虑,怎么办?规律又是什么? |
| ::: |
| :::success[答案 2]{close} |
| 为了让我们的工作更加便利,令这些个一次函数都是 |
| 容易发现,对于 |
| ::: |
| :::info[提示 3]{close} |
| 能不能再简化一下系数的表示方法呢? |
| ::: |
| :::success[答案 3]{close} |
| 我们令 |
| ::: |
| :::info[提示 4]{close} |
| 能不能得到解存在的条件呢?可以手动尝试一下。 |
| ::: |
| :::success[答案 4]{close} |
| 因此,在将 |
| 对系数进行差分(第 |
| 我们令 |
|---|
| :::info[提示 5]{close} |
| 能不能构造出一组满足全部的解的答案呢?可以考虑删掉一些对于答案没什么影响,或者太繁琐的东西。 |
| ::: |
| :::::success[答案 5]{close} |
| 我们使 |
其余的项,我们使
我们仍然验算
::::error[特性 bug]{close}
你忽然发现,样例中的
// p7117 Mivik 卷积
// Alea
#include <bits/stdc++.h>
using namespace std;
const int N=5e5+5,inf=0x3f3f3f3f;
int n,f[N],d[N]={-inf},B;
int main(){
cin>>n,--n;
for(int i=0;i<=n;++i) cin>>f[i];
if(n==0||n==1) cout<<"simple"<<endl<<1<<endl<<f[1]<<" "<<f[0]<<endl,exit(0);
B=f[0];
for(int i=1;i<=n;++i){
d[i]=f[i-1]-f[i];
if(d[i]<d[0]) cout<<"nice"<<endl,exit(0);
d[0]=max(d[0],d[i]);
}
for(int i=2;i<=n;++i) if(d[i]==0) B--;
cout<<"simple"<<endl<<n<<endl<<B-d[1]<<" "<<B<<endl;
for(int i=2;i<=n;++i){
if(d[i]!=0) cout<<-d[i]<<" "<<0<<endl;
else cout<<1<<" "<<1<<endl;
}
return 0;
}
::: :::warning[吐槽]{close} 这道题和贪心有半毛钱关系吗? :::