結果

問題 No.2509 Beam Shateki
ユーザー tailstails
提出日時 2024-04-23 18:21:42
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 2,074 bytes
コンパイル時間 1,357 ms
コンパイル使用メモリ 29,568 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 18:21:45
合計ジャッジ時間 2,547 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 0 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 0 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 0 ms
5,376 KB
testcase_11 AC 0 ms
5,376 KB
testcase_12 AC 0 ms
5,376 KB
testcase_13 AC 0 ms
5,376 KB
testcase_14 AC 0 ms
5,376 KB
testcase_15 AC 0 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 0 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 0 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 0 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 0 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 0 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 0 ms
5,376 KB
testcase_34 AC 0 ms
5,376 KB
testcase_35 AC 0 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 1 ms
5,376 KB
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 0 ms
5,376 KB
testcase_41 AC 0 ms
5,376 KB
testcase_42 AC 1 ms
5,376 KB
testcase_43 AC 1 ms
5,376 KB
testcase_44 AC 1 ms
5,376 KB
testcase_45 AC 0 ms
5,376 KB
testcase_46 AC 0 ms
5,376 KB
testcase_47 AC 1 ms
5,376 KB
testcase_48 AC 0 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
testcase_51 AC 0 ms
5,376 KB
testcase_52 AC 1 ms
5,376 KB
testcase_53 AC 1 ms
5,376 KB
testcase_54 AC 1 ms
5,376 KB
testcase_55 AC 1 ms
5,376 KB
testcase_56 AC 0 ms
5,376 KB
testcase_57 AC 1 ms
5,376 KB
testcase_58 AC 1 ms
5,376 KB
testcase_59 AC 0 ms
5,376 KB
testcase_60 AC 1 ms
5,376 KB
testcase_61 AC 0 ms
5,376 KB
testcase_62 AC 1 ms
5,376 KB
testcase_63 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:59: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
    7 | #define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);})
      |                                                           ^~~~~
main.c:139:9: note: in expansion of macro ‘wt1’
  139 |         wt1(z);
      |         ^~~
main.c:140:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  140 |         _exit(0);
      |         ^~~~~
main.c:140:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define wt(v) ({unsigned _z=v;do*--wp=_z%10+48;while(_z/=10);})
#define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);})
#define rep(v,e) for(typeof(e) v=0;v<e;++v)
#define max(a,b) (a>=b?a:b)
#define chmax(v,a) (v=v>=a?v:a)

int a[100];
int b[100];
int c[200];
int d[200];
int e[100][100];

int main(){
	rd_init();
	int h=rd();
	int w=rd();
	int z;
	{
		int a1=0,a2=0;
		rep(y,h){
			rep(x,w){
				int v=rd();
				a[y]+=v;
				b[x]+=v;
				c[y+x]+=v;
				d[y+w-1-x]+=v;
				e[y][x]=v;
			}
			if(a1<a[y]){
				a2=a1;
				a1=a[y];
			}else if(a2<a[y]){
				a2=a[y];
			}
		}
		z=a1+a2;
	}
	{
		int b1=0,b2=0;
		rep(x,w){
			if(b1<b[x]){
				b2=b1;
				b1=b[x];
			}else if(b2<b[x]){
				b2=b[x];
			}
		}
		chmax(z,b1+b2);
	}
	{
		int c1=0,c2=0;
		int d1=0,d2=0;
		rep(i,h+w-1){
			if(c1<c[i]){
				c2=c1;
				c1=c[i];
			}else if(c2<c[i]){
				c2=c[i];
			}
			if(d1<d[i]){
				d2=d1;
				d1=d[i];
			}else if(d2<d[i]){
				d2=d[i];
			}
		}
		chmax(z,c1+c2);
		chmax(z,d1+d2);
	}
	rep(y,h){
		rep(x,w){
			chmax(z,a[y]+b[x]-e[y][x]);
		}
		rep(i,h+w-1){
			{
				int t=a[y]+c[i];
				if(t>z){
					int x=i-y;
					if(x>=0&&x<w){
						t-=e[y][x];
					}
					chmax(z,t);
				}
			}
			{
				int t=a[y]+d[i];
				if(t>z){
					int x=y+w-1-i;
					if(x>=0&&x<w){
						t-=e[y][x];
					}
					chmax(z,t);
				}
			}
		}
	}
	rep(i,h+w-1){
		rep(x,w){
			{
				int t=b[x]+c[i];
				if(t>z){
					int y=i-x;
					if(y>=0&&y<h){
						t-=e[y][x];
					}
					chmax(z,t);
				}
			}
			{
				int t=b[x]+d[i];
				if(t>z){
					int y=i+1-w+x;
					if(y>=0&&y<h){
						t-=e[y][x];
					}
					chmax(z,t);
				}
			}
		}
		rep(j,h+w-1){
			int t=c[i]+d[j];
			if(t>z){
				if(!(i+j+1-w&1)){
					int y=i+j+1-w>>1;
					int x=i-j-1+w>>1;
					if(y>=0&&y<h&&x>=0&&x<w){
						t-=e[y][x];
					}
				}
				chmax(z,t);
			}
		}
	}
	wt1(z);
	_exit(0);
}
0