Submission #60293254


Source Code Expand

#include<bits/stdc++.h>
#include"atcoder/all"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll inf=1ll<<61;
typedef modint1000000007 mi;

int a[105][105],b[105][105];

int main(){
	int h,w;cin>>h>>w;
	rep(i,h)rep(j,w)cin>>a[i][j];
	rep(i,h)rep(j,w)cin>>b[i][j];
	ll ans=0;
	rep(i,h-1){
		rep(j,w-1){
			ans+=abs(a[i][j]-b[i][j]);
			int d=b[i][j]-a[i][j];
			a[i][j]+=d;
			a[i][j+1]+=d;
			a[i+1][j]+=d;
			a[i+1][j+1]+=d;
		}
	}

	rep(i,h){
		rep(j,w){
			if(a[i][j]!=b[i][j]){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	cout<<ans<<endl;
}

Submission Info

Submission Time
Task 079 - Two by Two(★3)
User Rho17
Language C++ 20 (gcc 12.2)
Score 3
Code Size 780 Byte
Status AC
Exec Time 4 ms
Memory 3768 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 3 / 3
Status
AC × 3
AC × 22
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt AC 1 ms 3492 KiB
hand_02.txt AC 4 ms 3768 KiB
hand_03.txt AC 3 ms 3580 KiB
hand_04.txt AC 3 ms 3524 KiB
random_01.txt AC 1 ms 3588 KiB
random_02.txt AC 1 ms 3584 KiB
random_03.txt AC 1 ms 3512 KiB
random_04.txt AC 2 ms 3632 KiB
random_05.txt AC 1 ms 3688 KiB
random_06.txt AC 1 ms 3500 KiB
random_07.txt AC 2 ms 3668 KiB
random_08.txt AC 2 ms 3616 KiB
random_09.txt AC 3 ms 3560 KiB
random_10.txt AC 1 ms 3544 KiB
random_11.txt AC 2 ms 3752 KiB
random_12.txt AC 1 ms 3464 KiB
random_13.txt AC 2 ms 3592 KiB
random_14.txt AC 2 ms 3704 KiB
random_15.txt AC 3 ms 3740 KiB
sample_01.txt AC 1 ms 3544 KiB
sample_02.txt AC 1 ms 3500 KiB
sample_03.txt AC 1 ms 3516 KiB