Codeforces Round #379 (Div. 2), problem: (D) Anton and Chess Solution in C

Hey guys I just tried the Anton and Chess problem , hope you might like my solution feel free to comment better solution .

#include
#include
typedef unsigned u;
u F(u a,u b){return(b>=a)+(b>a);}
char C[3][3],c[3];u D[3][3];
int main()
{
u q,x,y,a,b,dx,dy,dz,i,j;
for(i=-1;++i<3;)for(j=-1;++j<3;)D[i][j]=-1u; scanf("%u%u%u",&q,&x,&y); x^=(1u<<31);y^=(1u<<31); while(q--) { scanf("%s%u%u",c,&a,&b); a^=(1u<<31);b^=(1u<<31); dx=a>x?a-x:x-a;
dy=b>y?b-y:y-b;
if(dx!=0&&dy!=0&&dx!=dy)continue;
dz=dx>dy?dx:dy;
if(D[F(x,a)][F(y,b)]>dz)
{
D[F(x,a)][F(y,b)]=dz;
C[F(x,a)][F(y,b)]=*c;
}
}
for(i=-1;++i<3;)for(j=-1;++j<3;)if(C[i][j]) { if( ((i^j)&1)&&(C[i][j]=='R'||C[i][j]=='Q'))q=0; if(!((i^j)&1)&&(C[i][j]=='B'||C[i][j]=='Q'))q=0; } printf(q?"NO\n":"YES\n"); return 0; }

Can You Use Rechargeable...

Battery Compatibility: Lithium vs Rechargeable AA Can you save money...

How to Fix Blink...

Troubleshooting: Fixing Blink Camera Offline Errors If your Blink app...

Best Solar Panels and...

Top Accessories for the Blink Outdoor 4 Upgrade your Blink...

How to Adjust Blink...

Reducing False Alerts with Custom Motion Zones Tired of receiving...

Can You View Blink...

Alexa Integration: Streaming Live Feeds to Echo Show Because Blink...

How Good Is the...

Night Vision & Motion Detection Performance Test How well does...

Can You Use Rechargeable AA Batteries in the Blink Outdoor 4?

Battery Compatibility: Lithium vs Rechargeable AA Can you save money by using rechargeable AA batteries (Eneloop/NiMH) or standard alkaline batteries in your Blink Outdoor 4? 📹...

How to Fix Blink Outdoor 4 Offline or Sync Module Disconnected Errors

Troubleshooting: Fixing Blink Camera Offline Errors If your Blink app reports "Camera Offline" or "Sync Module Disconnected", follow these 3 quick troubleshooting steps. 📹 Check Blink...

Best Solar Panels and Mounting Brackets for the Blink Outdoor 4

Top Accessories for the Blink Outdoor 4 Upgrade your Blink system with solar power and specialized mounting brackets. 📹 Check Blink Accessories on Amazon As an Amazon...

How to Adjust Blink Outdoor 4 Motion Zones and Reduce False Alerts

Reducing False Alerts with Custom Motion Zones Tired of receiving phone notifications every time a car drives by or a tree branch sways in the...

Can You View Blink Outdoor 4 Live Stream on Amazon Echo Show and Alexa Devices?

Alexa Integration: Streaming Live Feeds to Echo Show Because Blink is an Amazon company, Alexa integration is seamless and built-in. 📹 Check Blink Outdoor 4 Price...

How Good Is the Night Vision and Motion Detection on the Blink Outdoor 4?

Night Vision & Motion Detection Performance Test How well does the Outdoor 4 detect intruders and record video in complete darkness? 📹 Check Blink Outdoor 4...

How to Install and Mount the Blink Outdoor 4 Camera Outdoors (Step-by-Step)

Mounting & Positioning Your Blink Outdoor 4 Camera Installing the wireless Blink Outdoor 4 takes less than 10 minutes per camera with basic household tools. 📹...

Is the Blink Outdoor 4 Waterproof? Extreme Weather and Rain Test

Weather Resistance & Temperature Operating Limits Outdoor security cameras must endure torrential rainstorms, sub-zero snow, and blistering summer heat. 📹 Check Blink Outdoor 4 Price on...

Do You Need a Subscription for Blink Outdoor 4? Free Local Storage via Sync Module 2 Guide

Using Blink Outdoor 4 Without a Monthly Subscription Unlike most smart camera brands that hide video recording behind paywalls, Blink lets you record locally for...