Submission #18332447


Source Code Expand

#include "bits/stdc++.h"
using namespace std;

#define ll long long

ll r1,c1,r2,c2;

int main()
{
	cin>>r1>>c1>>r2>>c2;

	ll ans=(abs(r1-r2)+abs(c1-c2)+2)/3;
	ans=min(ans,3ll);

	if((r1+c1)%2==(r2+c2)%2) ans=min(ans,2ll);

	for(int dx=-3;dx<=3;dx++)
	{
		for(int dy=-3;dy<=3;dy++)
		{
			if(abs(dx)+abs(dy)>3) continue;
			//cout<<dx<<" "<<dy<<endl;

			int nr=r1+dx,nc=c1+dy;
			if((nr-nc)==(r2-c2)) ans=min(ans,2ll);
			if((nr+nc)==(r2+c2)) ans=min(ans,2ll);
		}
	}

	if((r1-c1)==(r2-c2)) ans=min(ans,1ll);
	if((r1+c1)==(r2+c2)) ans=min(ans,1ll);

	cout<<ans;
}

Submission Info

Submission Time
Task C - Super Ryuma
User dush1729
Language C++ (GCC 9.2.1)
Score 300
Code Size 597 Byte
Status AC
Exec Time 6 ms
Memory 3588 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 30
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand_01.txt, hand_02.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, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
hand_01.txt AC 6 ms 3408 KiB
hand_02.txt AC 2 ms 3464 KiB
random_01.txt AC 2 ms 3356 KiB
random_02.txt AC 3 ms 3468 KiB
random_03.txt AC 2 ms 3356 KiB
random_04.txt AC 2 ms 3456 KiB
random_05.txt AC 2 ms 3456 KiB
random_06.txt AC 1 ms 3356 KiB
random_07.txt AC 2 ms 3508 KiB
random_08.txt AC 2 ms 3456 KiB
random_09.txt AC 3 ms 3504 KiB
random_10.txt AC 3 ms 3452 KiB
random_11.txt AC 3 ms 3452 KiB
random_12.txt AC 2 ms 3356 KiB
random_13.txt AC 2 ms 3360 KiB
random_14.txt AC 2 ms 3588 KiB
random_15.txt AC 3 ms 3508 KiB
random_16.txt AC 3 ms 3452 KiB
random_17.txt AC 3 ms 3352 KiB
random_18.txt AC 2 ms 3516 KiB
random_19.txt AC 2 ms 3412 KiB
random_20.txt AC 2 ms 3456 KiB
random_21.txt AC 3 ms 3464 KiB
random_22.txt AC 3 ms 3516 KiB
random_23.txt AC 2 ms 3508 KiB
random_24.txt AC 2 ms 3292 KiB
sample_01.txt AC 2 ms 3456 KiB
sample_02.txt AC 2 ms 3588 KiB
sample_03.txt AC 2 ms 3584 KiB
sample_04.txt AC 2 ms 3504 KiB