提出 #72745279


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
int n,d;
int a[505][505];
int to[505][505][2];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++) cin>>a[i][j],a[i][j]+=2000;
	}
	int t0=0,t1=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			to[i][j][0]=min(a[i][j]%(2*d),2*d-a[i][j]%(2*d));
			to[i][j][1]=min((a[i][j]+d)%(2*d),2*d-(a[i][j]+d)%(2*d));
			t0+=to[i][j][(i+j)&1];
			t1+=to[i][j][!((i+j)&1)];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(((i+j)&1)==(t0<t1)){
				if((a[i][j]+d)%(2*d)<2*d-(a[i][j]+d)%(2*d)) cout<<a[i][j]-(a[i][j]+d)%(2*d)-2000<<" ";
				else cout<<a[i][j]+2*d-(a[i][j]+d)%(2*d)-2000<<" ";
			}else{
				if(a[i][j]%(2*d)<2*d-a[i][j]%(2*d)) cout<<a[i][j]-a[i][j]%(2*d)-2000<<" ";
				else cout<<a[i][j]+2*d-a[i][j]%(2*d)-2000<<" ";
			}
		}
		cout<<"\n";
	}
} 

提出情報

提出日時
問題 A - Adjacent Difference
ユーザ george0929
言語 C++23 (GCC 15.2.0)
得点 600
コード長 919 Byte
結果 AC
実行時間 25 ms
メモリ 6800 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 2
AC × 55
セット名 テストケース
Sample 01_sample_01.txt, 01_sample_02.txt
All 01_sample_01.txt, 01_sample_02.txt, 02_rand_1_01.txt, 02_rand_1_02.txt, 02_rand_1_03.txt, 02_rand_1_04.txt, 02_rand_1_05.txt, 02_rand_1_06.txt, 02_rand_1_07.txt, 02_rand_1_08.txt, 02_rand_1_09.txt, 02_rand_1_10.txt, 02_rand_1_11.txt, 02_rand_1_12.txt, 02_rand_1_13.txt, 02_rand_1_14.txt, 02_rand_1_15.txt, 03_rand_2_01.txt, 03_rand_2_02.txt, 03_rand_2_03.txt, 03_rand_2_04.txt, 03_rand_2_05.txt, 03_rand_2_06.txt, 03_rand_2_07.txt, 03_rand_2_08.txt, 03_rand_2_09.txt, 03_rand_2_10.txt, 03_rand_2_11.txt, 03_rand_2_12.txt, 03_rand_2_13.txt, 03_rand_2_14.txt, 03_rand_2_15.txt, 04_almost_const_01.txt, 04_almost_const_02.txt, 04_almost_const_03.txt, 04_almost_const_04.txt, 04_almost_const_05.txt, 05_stripe_01.txt, 05_stripe_02.txt, 05_stripe_03.txt, 05_stripe_04.txt, 05_stripe_05.txt, 05_stripe_06.txt, 05_stripe_07.txt, 05_stripe_08.txt, 06_bfs_01.txt, 06_bfs_02.txt, 06_bfs_03.txt, 06_bfs_04.txt, 06_bfs_05.txt, 06_bfs_06.txt, 06_bfs_07.txt, 06_bfs_08.txt, 06_bfs_09.txt, 06_bfs_10.txt
ケース名 結果 実行時間 メモリ
01_sample_01.txt AC 1 ms 3696 KiB
01_sample_02.txt AC 1 ms 3688 KiB
02_rand_1_01.txt AC 1 ms 3684 KiB
02_rand_1_02.txt AC 1 ms 3684 KiB
02_rand_1_03.txt AC 1 ms 3776 KiB
02_rand_1_04.txt AC 1 ms 3696 KiB
02_rand_1_05.txt AC 1 ms 3696 KiB
02_rand_1_06.txt AC 5 ms 4936 KiB
02_rand_1_07.txt AC 3 ms 4624 KiB
02_rand_1_08.txt AC 14 ms 5732 KiB
02_rand_1_09.txt AC 16 ms 5772 KiB
02_rand_1_10.txt AC 9 ms 5312 KiB
02_rand_1_11.txt AC 25 ms 6640 KiB
02_rand_1_12.txt AC 25 ms 6704 KiB
02_rand_1_13.txt AC 25 ms 6576 KiB
02_rand_1_14.txt AC 25 ms 6680 KiB
02_rand_1_15.txt AC 25 ms 6640 KiB
03_rand_2_01.txt AC 1 ms 3760 KiB
03_rand_2_02.txt AC 1 ms 3776 KiB
03_rand_2_03.txt AC 1 ms 3780 KiB
03_rand_2_04.txt AC 1 ms 3696 KiB
03_rand_2_05.txt AC 1 ms 3684 KiB
03_rand_2_06.txt AC 4 ms 4680 KiB
03_rand_2_07.txt AC 4 ms 4776 KiB
03_rand_2_08.txt AC 6 ms 5192 KiB
03_rand_2_09.txt AC 1 ms 3632 KiB
03_rand_2_10.txt AC 9 ms 5208 KiB
03_rand_2_11.txt AC 22 ms 6604 KiB
03_rand_2_12.txt AC 22 ms 6620 KiB
03_rand_2_13.txt AC 22 ms 6616 KiB
03_rand_2_14.txt AC 22 ms 6720 KiB
03_rand_2_15.txt AC 22 ms 6652 KiB
04_almost_const_01.txt AC 22 ms 6696 KiB
04_almost_const_02.txt AC 21 ms 6604 KiB
04_almost_const_03.txt AC 19 ms 6680 KiB
04_almost_const_04.txt AC 21 ms 6580 KiB
04_almost_const_05.txt AC 20 ms 6620 KiB
05_stripe_01.txt AC 19 ms 6620 KiB
05_stripe_02.txt AC 20 ms 6640 KiB
05_stripe_03.txt AC 20 ms 6652 KiB
05_stripe_04.txt AC 20 ms 6800 KiB
05_stripe_05.txt AC 19 ms 6680 KiB
05_stripe_06.txt AC 20 ms 6616 KiB
05_stripe_07.txt AC 20 ms 6712 KiB
05_stripe_08.txt AC 21 ms 6800 KiB
06_bfs_01.txt AC 19 ms 6696 KiB
06_bfs_02.txt AC 19 ms 6704 KiB
06_bfs_03.txt AC 19 ms 6632 KiB
06_bfs_04.txt AC 20 ms 6604 KiB
06_bfs_05.txt AC 20 ms 6680 KiB
06_bfs_06.txt AC 20 ms 6680 KiB
06_bfs_07.txt AC 19 ms 6712 KiB
06_bfs_08.txt AC 19 ms 6604 KiB
06_bfs_09.txt AC 19 ms 6572 KiB
06_bfs_10.txt AC 20 ms 6628 KiB