QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#442316#6857. Easy problem IIAcoippAC ✓1872ms4868kbC++143.3kb2024-06-15 11:03:382024-06-15 11:03:38

Judging History

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

  • [2024-06-15 11:03:38]
  • 评测
  • 测评结果:AC
  • 用时:1872ms
  • 内存:4868kb
  • [2024-06-15 11:03:38]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<cstdio>
#define N 100005
#define ll long long
using namespace std;
inline char nc(){
	static char buf[1000000],*p=buf,*q=buf;
	return p==q&&(q=(p=buf)+fread(buf,1,1000000,stdin),p==q)?EOF:*p++;
}
inline int read(){
	int res = 0;
	char c = nc();
	while(c<'0'||c>'9')c=nc();
	while(c<='9'&&c>='0')res=res*10+c-'0',c=nc();
	return res;
}
char obuf[1<<21],*p3=obuf; 
inline void pc(char c){ 
	p3-obuf<=(1<<20)?(*p3++=c):(fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=c); 
} 
inline void write(ll x){ 
	if(x<0) pc('-'),x=-x; 
	if(x>9) write(x/10); 
	pc(x%10+'0'); 
}
int T,n,m,i,opt,l,r,x;
ll ans,a[N];
int main(){
	T=read(),n=read(),m=read();
	for(i=1;i<=n;i++) a[i]=read();
	while(m--){
		opt=read(),l=read(),r=read();
		if(opt==1){
			x=read();
			for(i=l;i<=r;){
				if(i+7<=r){
					a[i]<x?a[i]=x-a[i]:a[i]+=x;
					a[i+1]<x?a[i+1]=x-a[i+1]:a[i+1]+=x;
					a[i+2]<x?a[i+2]=x-a[i+2]:a[i+2]+=x;
					a[i+3]<x?a[i+3]=x-a[i+3]:a[i+3]+=x;
					a[i+4]<x?a[i+4]=x-a[i+4]:a[i+4]+=x;
					a[i+5]<x?a[i+5]=x-a[i+5]:a[i+5]+=x;
					a[i+6]<x?a[i+6]=x-a[i+6]:a[i+6]+=x;
					a[i+7]<x?a[i+7]=x-a[i+7]:a[i+7]+=x;
					i+=8;
				}
				else a[i]<x?a[i]=x-a[i]:a[i]+=x,i++;
			}
		}
		else{
			long long sum1=0,sum2=0,sum3=0,sum4=0,sum5=0,sum6=0,sum7=0,sum8=0;
			for(i=l;i+8<=r;i+=8){
				sum1+=a[i];
				sum2+=a[i+1];
				sum3+=a[i+2];
				sum4+=a[i+3];
				sum5+=a[i+4];
				sum6+=a[i+5];
				sum7+=a[i+6];
				sum8+=a[i+7];
			}
			for(;i<=r;i++) sum8+=a[i];
			write(sum1+sum2+sum3+sum4+sum5+sum6+sum7+sum8),pc('\n');
		}
	}
	return fwrite(obuf,p3-obuf,1,stdout),0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1872ms
memory: 4868kb

input:

1
100000 100000
9994250 1 9999152 1 9996205 1 9993920 1 9992936 1 9999312 1 9994863 1 9999950 1 9994702 1 9998302 1 9997460 1 9995584 1 9990858 1 9995764 1 9992400 1 9992970 1 9993486 1 9992200 1 9991250 1 9990336 1 9994212 1 9992704 1 9999400 1 9994826 1 9996272 1 9995920 1 9994960 1 9996400 1 9990...

output:

474104664177
469903014249
480933011291
483822399944
484396591822
485195157450
476873328231
500050522935
490495899612
455001143708
459350186600
463088605817
452789422852
457530804729
478921256445
483860248443
460953094343
461203887676
471567676461
499102979676
483610787357
490750641096
468023668995
4...

result:

ok 85563 lines