QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22951#2887. 区间矩阵乘法hy_zheng_zai_nei_juan#TL 0ms5652kbC++201.8kb2022-03-11 12:03:202022-04-30 02:10:22

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 02:10:22]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:5652kb
  • [2022-03-11 12:03:20]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<sstream>
#include<cctype>
#include<cmath>
#include<iomanip>
#include<map>
#include<stack>
#include<set>
#include<functional>
#define in(x) x=read()
#define qr read()
// #define int ll
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
namespace fastIO
{
    #define BUF_SIZE 100000
    bool IOerror=0;
    inline char nc()
	{
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline ll read()
	{
        bool sign=0; char ch=nc();ll x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return 0;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
        return x;
    }
    #undef BUF_SIZE
};
using namespace fastIO;
#define blk 450
unsigned sum[200010][500];
int a[1000010];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n=qr;
	for(int i=1;i<=n;i++)in(a[i]);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=max(i,blk);j++)sum[i][j]=sum[i-j][j]+a[i];
	}
	int m=qr;
	while(m--)
	{
		int d=qr,p1=qr,p2=qr;
		unsigned ans=0;
		for(int p=p2,j=0;j<d;p+=d,j++)
		{
			// cout<<p+d-1<<"-"<<p-1<<'\n';
			// cout<<j<<":"<<(sum[p+d-1][1]-sum[p-1][1])<<' '<<(sum[p1+d*(d-1)+j][d]-sum[p1+j-d][d])<<'\n';
			ans+=(sum[p+d-1][1]-sum[p-1][1])*(sum[p1+d*(d-1)+j][d]-sum[p1+j-d][d]);
		}
		cout<<ans<<'\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8
1 2 2 2 2 2 1 1
2
2 2 2
1 3 7

output:

32
2

result:

ok 2 lines

Test #2:

score: -100
Time Limit Exceeded

input:

200000
110569 155 159393 154631 169597 134901 75060 60085 189794 169502 10184 170809 170894 5697 83892 99814 97985 11604 39943 171446 77088 44463 60432 121559 54578 115592 151722 115322 147103 126168 55464 42044 181426 196809 58680 173065 136429 76030 109558 78475 161094 46875 1564 177386 108053 828...

output:


result: