/ SB域 /

记录详情

Memory Exceeded

/in/foo.cc:1:0: warning: ignoring #pragma G  [-Wunknown-pragmas]
 # pragma G++ optimze(2) 
 
/in/foo.cc: In function 'long long int read()':
/in/foo.cc:10:22: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  int x; scanf("%d",&x);
                    ~~^
/in/foo.cc: In function 'void write(long long int)':
/in/foo.cc:15:15: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
  printf("%d",x);
               ^
/in/foo.cc: In function 'int main()':
/in/foo.cc:73:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for (int i=1;i<=n;i++)
  ^~~
/in/foo.cc:78:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   for (int i=1;i<=n;i++)
   ^~~
/in/foo.cc:78:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
/in/foo.cc:81:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    char opt;
    ^~~~
# 状态 耗时 内存占用
#1 Memory Exceeded ≥850ms ≥500.0 MiB
#2 Memory Exceeded ≥598ms ≥500.0 MiB
#3 Memory Exceeded ≥617ms ≥500.0 MiB
#4 Memory Exceeded ≥616ms ≥500.0 MiB
#5 Memory Exceeded ≥635ms ≥500.0 MiB
#6 Memory Exceeded ≥600ms ≥500.0 MiB
#7 Memory Exceeded ≥739ms ≥500.0 MiB
#8 Memory Exceeded ≥686ms ≥500.0 MiB
#9 Memory Exceeded ≥896ms ≥500.0 MiB
#10 Memory Exceeded ≥634ms ≥500.0 MiB
#11 Memory Exceeded ≥676ms ≥500.0 MiB
#12 Memory Exceeded ≥716ms ≥500.0 MiB
#13 Memory Exceeded ≥714ms ≥500.0 MiB
#14 Memory Exceeded ≥629ms ≥500.0 MiB
#15 Memory Exceeded ≥623ms ≥500.0 MiB
#16 Memory Exceeded ≥649ms ≥500.0 MiB
#17 Memory Exceeded ≥696ms ≥500.0 MiB
#18 Memory Exceeded ≥613ms ≥500.0 MiB
#19 Memory Exceeded ≥634ms ≥500.0 MiB
#20 Memory Exceeded ≥624ms ≥500.0 MiB
#21 Memory Exceeded ≥632ms ≥500.0 MiB
#22 Memory Exceeded ≥651ms ≥500.0 MiB
#23 Memory Exceeded ≥738ms ≥500.0 MiB
#24 Memory Exceeded ≥718ms ≥500.0 MiB
#25 Memory Exceeded ≥708ms ≥500.0 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; scanf("%d",&x);
	return x;
}
inline void write(int x)
{
	printf("%d",x);
}
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++
递交时间
2018-11-05 13:42:55
评测时间
2018-11-05 13:42:55
评测机
分数
0
总耗时
≥16902ms
峰值内存
≥500.0 MiB