/ SB域 /

记录详情

Time Exceeded

foo.cc:1: warning: ignoring '#pragma G ' [-Wunknown-pragmas]
    1 | # pragma G++ optimze(2)
      | 
foo.cc: In function 'int main()':
foo.cc:77:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   77 |         for (int i=1;i<=n;i++)
      |         ^~~
foo.cc:82:10: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   82 |          for (int i=1;i<=n;i++)
      |          ^~~
foo.cc:82:10: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
foo.cc:85:11: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   85 |           char opt;
      |           ^~~~
[Hydro](https://hydro.ac)提供评测服务
# 状态 耗时 内存占用
#1 Accepted 918ms 375.992 MiB
#2 Accepted 714ms 376.367 MiB
#3 Accepted 373ms 376.367 MiB
#4 Accepted 356ms 376.383 MiB
#5 Accepted 1589ms 392.133 MiB
#6 Accepted 1499ms 396.492 MiB
#7 Accepted 1958ms 400.242 MiB
#8 Accepted 1184ms 392.992 MiB
#9 Accepted 1699ms 395.105 MiB
#10 Accepted 1600ms 395.102 MiB
#11 Accepted 1274ms 395.867 MiB
#12 Accepted 1252ms 395.867 MiB
#13 Time Exceeded ≥2114ms ≥395.367 MiB
#14 Accepted 884ms 388.242 MiB
#15 Accepted 1536ms 393.867 MiB
#16 Accepted 1499ms 394.746 MiB
#17 Accepted 1560ms 395.867 MiB
#18 Time Exceeded ≥2000ms ≥397.117 MiB
#19 Accepted 1703ms 396.992 MiB
#20 Accepted 1758ms 396.992 MiB
#21 Accepted 1982ms 403.242 MiB
#22 Time Exceeded ≥2092ms ≥402.254 MiB
#23 Accepted 1994ms 402.371 MiB
#24 Time Exceeded ≥2080ms ≥403.742 MiB
#25 Accepted 1800ms 403.617 MiB

代码

# pragma G++ optimze(2) 
# include<bits/stdc++.h>
# define int long long
using namespace std;
const int MAXN=3505;
int a[MAXN][MAXN],d[MAXN][MAXN];
int n,m;
inline int read()
{
    int X=0,w=0;char c=0;
    while (!(c>='0'&&c<='9')) w|=c=='-',c=getchar();
    while ((c>='0'&&c<='9')) X=(X<<1)+(X<<3)+(c^48),c=getchar();
    return w?-X:X;
}
inline void write(int x)
{
    if (x<0) { putchar('-'); x=-x;}
    if (x>9) write(x/10);
    putchar('0'+x%10);
}
inline void writeln(int x){write(x);putchar('\n');}
struct Tree{
	int c[MAXN][MAXN];
	Tree(){ memset(c,0,sizeof(c));}
	inline void update(int x,int y,int z){
		for (int i=x;i<=n;i+=i&(-i))
		 for (int j=y;j<=m;j+=j&(-j)){
		 	c[i][j]+=z;
		 }
	}	
}T1,T2,T3,T4;
# define A (x+1)
# define B (y+1)
inline int ask(int x,int y){
	int ret=0;
	for (int i=x;i;i-=i&(-i))
	 for (int j=y;j;j-=j&(-j))
	  ret+=A*B*T1.c[i][j]-B*T2.c[i][j]-A*T3.c[i][j]+T4.c[i][j];
	return ret;  
}
inline void add(int x,int y,int val){
	T1.update(x,y,val);   T2.update(x,y,val*x);
	T3.update(x,y,val*y); T4.update(x,y,val*x*y);
}
inline void work1()
{
	int x1=read(),y1=read(),x2=read(),y2=read();
	int ans=ask(x2,y2)-ask(x2,y1-1)-ask(x1-1,y2)+ask(x1-1,y1-1);
	writeln(ans);
}
inline void work2()
{
	int x1=read(),y1=read(),x2=read(),y2=read(),d=read();
	add(x1,y1,d); add(x1,y2+1,-d);
	add(x2+1,y1,-d); add(x2+1,y2+1,d);
}
inline void work3()
{
	int x1=read(),y1=read(),x2=read(),y2=read(),d=read(); d=-d;
	add(x1,y1,d); add(x1,y2+1,-d);
	add(x2+1,y1,-d); add(x2+1,y2+1,d);
}
inline void work4()
{
	int x1=read(),y1=read();
	int x2=x1,y2=y1;
	int ans=ask(x2,y2)-ask(x2,y1-1)-ask(x1-1,y2)+ask(x1-1,y1-1);
	writeln(ans);
}
signed main()
{
	#ifdef LOCAL
		freopen("7.in","r",stdin);
		freopen("7.out","w",stdout);
	#endif
	n=read();m=read();
	for (int i=1;i<=n;i++)
	 for (int j=1;j<=m;j++) {
	 	a[i][j]=read();
		d[i][j]=a[i][j]-a[i-1][j]-a[i][j-1]+a[i-1][j-1];  
	 }
	 for (int i=1;i<=n;i++)
	  for (int j=1;j<=m;j++)
	  	add(i,j,d[i][j]);
	  char opt;
	  while (true) {
	  	cin>>opt;
	  	switch (opt) {
	  		case 'Q':work1();break;
			case 'A':work2();break;
			case 'D':work3();break;
			case 'F':work4();break;
			case 'E':goto exit;break;  	
		}
	  }
	  exit:;
	return 0;
} 

信息

递交者
类型
递交
题目
二维数列 (U50446)
题目数据
下载
语言
C++
递交时间
2022-08-10 20:55:10
评测时间
2022-08-10 20:55:10
评测机
分数
84
总耗时
≥37431ms
峰值内存
≥403.742 MiB