Codeforces Round #385 (Div. 2), problem: (B) Hongcow Solves A Puzzle Solution in C/C++

Affiliate Disclosure: eBlogarithm is reader-supported. When you buy through links on our site, we may earn an affiliate commission as an Amazon Associate at no extra cost to you.

#include <limits.h>
#include <stdio.h>

int main() {
	int i, j, n, m, cnt, imin, jmin, imax, jmax;
	static char cc[500][501];

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%s", cc[i]);
	imin = jmin = INT_MAX;
	imax = jmax = 0;
	cnt = 0;
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			if (cc[i][j] == 'X') {
				cnt++;
				if (imin > i)
					imin = i;
				if (imax < i)
					imax = i;
				if (jmin > j)
					jmin = j;
				if (jmax < j)
					jmax = j;
			}
	printf("%s\n", (imax - imin + 1) * (jmax - jmin + 1) != cnt ? "NO" : "YES");
	return 0;
}
[the_ad id="1072"]




Advertisement

spot_img

If a chatbot prompt...

When news recently surfaced about an alleged breach of...

We Tested Viral Kitchen...

📢 As an Amazon Associate, I earn from qualifying...

NBA Trade Rumors: Potential...

The NBA landscape is constantly shifting, and recent contract...

The Ultimate Viral Kitchen...

📢 As an Amazon Associate, I earn from qualifying...

Is it OK to...

Lovebirds are famous for their vibrant personalities, affectionate nature,...

The Real Truth About...

📢 As an Amazon Associate, I earn from qualifying...

If a chatbot prompt like ‘find Australian medicine statistics’ results in a website breach, the responsibility does not lie with a piece of code

When news recently surfaced about an alleged breach of Australia’s Medicare computer systems triggered by an automated artificial intelligence tool, public alarm escalated quickly....

We Tested Viral Kitchen Gadgets Here Is What You Must Know

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...

NBA Trade Rumors: Potential RFA Targets, Fallout for Jalen Duren, & the Big Board

The NBA landscape is constantly shifting, and recent contract updates regarding Detroit Pistons center Jalen Duren have created significant ripples across the league’s transactional...

The Ultimate Viral Kitchen Gadgets Guide You Didnt Know You Needed

📢 As an Amazon Associate, I earn from qualifying purchases.If you had told me six months ago that a single purchase would change how...

Is it OK to play bird sounds for my lovebird?

Lovebirds are famous for their vibrant personalities, affectionate nature, and expressive vocalizations. Because they are highly social flock animals in the wild, many owners...

The Real Truth About Viral Kitchen Gadgets Before You Buy

📢 As an Amazon Associate, I earn from qualifying purchases.I stumbled across this while desperately trying to fix a recurring problem in my routine....

ASUS ROG Launches The Gladius IV Ace Gaming Mouse

Competitive PC gamers and hardware enthusiasts have something exciting to upgrade their battle stations with this season. Republic of Gamers has officially unveiled the...

Why Viral Kitchen Gadgets Is Currently Breaking the Internet

📢 As an Amazon Associate, I earn from qualifying purchases.After putting the Viral Kitchen Gadgets through a proper 30-day real-world test, I can tell...

Tech Workers Made ChatGPT Drive a Toyota Corolla

In an unexpected and creative showcase of modern artificial intelligence, a group of tech enthusiasts and engineers in San Francisco managed to connect OpenAI's...