您的位置:首页 > 其它

codeforces 183A Headquarters

2012-05-07 20:21 232 查看
上次比赛比较有趣的一道题目, 就做了这一题...

初看不好想,经过分析,就会发现其实就是让你求一个矩阵面积。

比如说 我定义 左上 右下就是 来增长 边, 定义 左下右上 来增长 宽, 上左下右 来增长 宽和边。

ans = l * h

View Code

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
using namespace std;
typedef __int64 LL;
#define inf 10000000
#define N 20010
int main (){
LL n, num[5];
char str[5];
while (scanf ("%I64d", &n) != EOF) {
memset(num, 0,sizeof(num));
for (LL i = 0; i < n; ++i) {
scanf ("%s", str);
if(strcmp (str, "UR")==0) num[1] ++;
if(strcmp (str, "UL")==0) num[2] ++;
if(strcmp (str, "DR")==0) num[4] ++;
if(strcmp (str, "DL")==0) num[3] ++;
if(strcmp (str, "ULDR")==0) num[0] ++;
}
LL len1, len2, ans;
len1 = 1 + num[1] + num[3] +num[0];
len2 = 1 + num[2] + num[4] +num[0];
ans = len1 *len2;
printf("%I64d\n", ans);

}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: