結果

問題 No.5026 Spectrum Router
コンテスト
ユーザー 👑 tails
提出日時 2026-11-23 22:51:29
言語 cLay
(20250308-1 + boost 1.92.0 + ACL)
コンパイル:
clayc _filename_
実行:
./a.out
結果
AC  
実行時間 1,872 ms / 2,000 ms
+ 37µs
コード長 1,200 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,440 ms
コンパイル使用メモリ 203,692 KB
実行使用メモリ 6,400 KB
スコア 1,159,097
最終ジャッジ日時 2026-11-23 22:57:13
合計ジャッジ時間 103,091 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge6_0
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

Timer timer;
Rand rnd;

constexpr int n=64;
int a[4n],c[n][n],bc[n][n],bv=0;

int f(int y,int x,int dy,int dx){
	int oy=y;
	int ox=x;
	int cc=0;
	while(1){
		y+=dy;
		x+=dx;
		if(y<0) return x;
		if(x>=n) return y+n;
		if(y>=n) return 3n-1-x;
		if(x<0) return 4n-1-y;
		if(y==oy&&x==ox&&++cc==2){
			return -1;
		}
		if(c[y][x]==1){
			(dy,dx)=(-dx,-dy);
		}
		if(c[y][x]==2){
			(dy,dx)=(dx,dy);
		}
	}
}

{
	timer.set();
	int @n_;
	rd(a(4n));
	while(timer.get()<1.9){
		rep(y,n){
			rep(x,n){
				c[y][x]=0;
				int t0=f(y,x,1,0);
				int t1=f(y,x,0,-1);
				int t2=f(y,x,-1,0);
				int t3=f(y,x,0,1);
				if(t0>=0&&t1>=0&&t2>=0&&t3>=0&&t0!=t1&&t0!=t3){
					int s0=t0*a[t2]+t2*a[t0]+t1*a[t3]+t3*a[t1];
					int s1=t0*a[t3]+t3*a[t0]+t1*a[t2]+t2*a[t1];
					int s2=t0*a[t1]+t1*a[t0]+t2*a[t3]+t3*a[t2];
					c[y][x]= s1>s2 ? s1>s0?1:0 : s2>s0?2:0;
				}
			}
		}
		int v=0;
		rep(i,n){
			int t0=f(0,i,1,0);
			v+=i*a[t0]+t0*a[i];
			int t1=f(i,0,0,1);
			v+=i*a[t1]+t1*a[i];
		}
		if(bv<v){
			bv=v;
			rep(y,n){
				rep(x,n){
					bc[y][x]=c[y][x];
				}
			}
		}else{
			rep(y,n){
				rep(x,n){
					c[y][x]=rnd.get(3);
				}
			}
		}
	}
	rep(y,n){
		rep(x,n){
			wtN(bc[y][x]);
		}
		wt("");
	}
}
0