CF1305E Kuroni and the Score Distribution(构造)
Posted goto_1600
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CF1305E Kuroni and the Score Distribution(构造)相关的知识,希望对你有一定的参考价值。
Link
题意:
思路:
先构造1,n直到溢出了位置,然后考虑加n,如果单纯加n,那么对于前面贡献是
n
2
\\frac{n}{2}
2n,然后发现n每隔2个数对前面的贡献都会减1,感性的理解,就是,之前n和一个值能匹配x,现在x变大了,n怎么匹配也匹配不了了,那么暴力加n知道刚好能满足m就行了,然后最妙的就是如何处理剩下的数,要造成0贡献,不如隔开构造,也就是说当前的最大值是max,前面有n个数,我们可以构造1e9-n*(maxv+1),1e9-(n-1)*(maxv+1)…
代码:
//#pragma GCC target("avx")
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast")
// created by myq
#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cctype>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define x first
#define y second
typedef pair<int,int> pii;
const int N = 400010;
const int mod=998244353;
inline int read()
{
int res=0;
int f=1;
char c=getchar();
while(c>'9' ||c<'0')
{
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9')
{
res=(res<<3)+(res<<1)+c-'0';
}
return res;
}
//#define int long long
int n,m;
signed main()
{
int t;
// cin>>t;
t=1;
int cas=0;
while(t--){
cin>>n>>m;
int res=0;
for(int i=1;i<=n;i++){
res+=(i+1)/2-1;
}
// cout<<res<<endl;
if(res<m){
cout<<"-1"<<endl;
}
else{
int now=0;
int maxv=0;
bool flag=0;
int tt;
int id;
int pos=0;
for(int i=1;i<=n;i++)
{
if(now+(i+1)/2-1<=m){
cout<<i<<" ";
now+=(i+1)/2-1;
}
else
{
flag=1;
id=i;
// cout<<now<<endl;
tt=m-now;
while(1){
int cnt=0;
for(int j=1;j<=i-1;j++)
if(id-j<=i-1 && id-j>j)
cnt++;
// cout<<endl;
// cout<<id<<" "<<cnt<<endl;
// break;
if(cnt==tt)
break;
id++;
}
cout<<id<<" ";
pos=i;
break;
}
}
if(flag){
// cout<<pos<<endl;
for(int i=pos+1;i<=n;i++)
cout<<(int)1e9-(n-i+1)*(id+1)<<" ";
}
cout<<endl;
}
}
return 0;
}
/**
* In every life we have some trouble
* When you worry you make it double
* Don't worry,be happy.
**/
以上是关于CF1305E Kuroni and the Score Distribution(构造)的主要内容,如果未能解决你的问题,请参考以下文章
CF1305F Kuroni and the Punishment
CF1305D Kuroni and the Celebration
CF1305F Kuroni and the Punishment
cf 1305 E. Kuroni and the Score Distribution