QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#743603#6810. Array ConcatenationcaiwenWA 0ms3656kbC++141.2kb2024-11-13 19:36:402024-11-13 19:36:40

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 19:36:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3656kb
  • [2024-11-13 19:36:40]
  • 提交

answer

//Powered by COJ
//8a032d0f-62fb-44d8-b375-dbc492add052


#include<bits/stdc++.h>

using namespace std;
//#define int long long
typedef long long LL;
#define ii __int128
#define endl '\n'
const int M=20000;
#define mp make_pair
#define pr pair<int,int>
const int mod=1e9+7;
mt19937 rd(time(NULL));

void solve()
{
	int n,m;
	cin>>n>>m;
	vector<int> t(n+1);
	for(int i=1;i<=n;i++) cin>>t[i];
	vector<LL> sum(n+1),pre(n+2);
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+t[i];
	for(int i=n;i>=1;i--) pre[i]=pre[i+1]+t[i];
	ii ans1=0;
	ii ans2=0;
	for(int i=1;i<=n;i++) ans1+=sum[i],ans2+=pre[i];
	auto cal=[&](int n,int num,vector<int> &xl)
	{
		LL ans=0;
		for(int i=1;i<=n;i++) 
			ans=(ans+(1ll*xl[i]*((((1ll*n*num%mod-i+1+mod)%mod+n-i+1))%mod*num/2)%mod)%mod)%mod;
		return ans;
	};
	if(ans1>ans2)
	{
		LL num=1;
		for(int i=1;i<=m;i++) num=num*2%mod;
		cout<<cal(n,num,t)<<endl;
	}
	else
	{
		vector<int> xl(n*2+1);
		for(int i=1;i<=n;i++) xl[i]=t[n-i+1];
		for(int i=n+1;i<=n*2;i++) xl[i]=t[i-n];
		LL num=1;
		for(int i=1;i<m;i++) num=num*2%mod;
		cout<<cal(n*2,num,xl)<<endl;
	}
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int T;
	T=1;
	while(T--) solve();
}
	

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

input:

2 1
1 2

output:

15

result:

ok single line: '15'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

5 10
26463 39326 86411 75307 85926

output:

806275469

result:

ok single line: '806275469'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3656kb

input:

3 10000
329770536 859936159 696111818

output:

-676272728

result:

wrong answer 1st lines differ - expected: '325223749', found: '-676272728'