`
阿尔萨斯
  • 浏览: 4108908 次
社区版块
存档分类
最新评论

Codeforces 390A Inna and Alarm Clock(水题)

 
阅读更多

题目链接:Codeforces 390A Inna and Alarm Clock


题目大意:给出一些点,表示该点上有灯,每次可以关掉一排或者一竖的灯,问说最少需要关几次。


解题思路:水题,计算出横线的个数和竖线的个数,去最小值。


#include <stdio.h>
#include <string.h>
#include <iostream>

using namespace std;
const int N = 105;

int n, cx[N], cy[N];

int main () {
	int nx = 0, ny = 0, xi, yi;
	memset(cx, 0, sizeof(cx));
	memset(cy, 0, sizeof(cy));

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &xi, &yi);
		if (cx[xi] == 0) nx++;
		if (cy[yi] == 0) ny++;
		cx[xi]++; cy[yi]++;
	}
	printf("%d\n", min(nx, ny));
	return 0;
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics