結果

問題 No.2509 Beam Shateki
コンテスト
ユーザー 👑 tails
提出日時 2024-04-23 18:21:42
言語 C90(gcc15)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,074 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 105 ms
コンパイル使用メモリ 26,168 KB
最終ジャッジ日時 2026-02-24 01:19:17
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c: In function 'main':
main.c:25:21: error: expected ';' before 'y'
   25 |                 rep(y,h){
      |                     ^
main.c:8:32: note: in definition of macro 'rep'
    8 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                ^
main.c:25:21: error: 'y' undeclared (first use in this function)
   25 |                 rep(y,h){
      |                     ^
main.c:8:36: note: in definition of macro 'rep'
    8 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                    ^
main.c:25:21: note: each undeclared identifier is reported only once for each function it appears in
   25 |                 rep(y,h){
      |                     ^
main.c:8:36: note: in definition of macro 'rep'
    8 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                    ^
main.c:26:29: error: expected ';' before 'x'
   26 |                         rep(x,w){
      |                             ^
main.c:8:32: note: in definition of macro 'rep'
    8 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                ^
main.c:26:29: error: 'x' undeclared (first use in this function)
   26 |                         rep(x,w){
      |                             ^
main.c:8:36: note: in definition of macro 'rep'
    8 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                    ^
main.c:45:21: error: expected ';' before 'x'
   45 |                 rep(x,w){
      |                     ^
main.c:8:32: note: in definition of macro 'rep'
    8 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                ^
main.c:58:21: error: expected ';' before 'i'
   58 |                 rep(i,h+w-1){
      |                     ^
main.c:8:32: note: in definition of macro 'rep'
    8 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                ^
main.c:58:21: error: 'i' undeclared (first use in this function)
   58 |      

ソースコード

diff #
raw source code

#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