Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit
Status

Description

Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!

The cake is a n × n square consisting of equal squares with side length
1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly started to put the chocolates on the cake. The value of Famil Door's happiness will be equal to the number of pairs of cells with
chocolates that are in the same row or in the same column of the cake. Famil Doors's family is wondering what is the amount of happiness of Famil going to be?

Please, note that any pair can be counted no more than once, as two different cells can't share both the same row and the same column.

Input

In the first line of the input, you are given a single integer
n (1 ≤ n ≤ 100) — the length of the side of the cake.

Then follow n lines, each containing
n characters. Empty cells are denoted with '.', while cells that contain chocolates are denoted by 'C'.

Output

Print the value of Famil Door's happiness, i.e. the number of pairs of chocolate pieces that share the same row or the same column.

Sample Input

Input
3
.CC
C..
C.C
Output
4
Input
4
CC..
C..C
.CC.
.CC.
Output
9

Sample Output

Hint

If we number rows from top to bottom and columns from left to right, then, pieces that share the same row in the first sample are:

  1. (1, 2) and (1, 3)
  2. (3, 1) and (3, 3)

Pieces that share the same column are:

  1. (2, 1) and (3, 1)
  2. (1, 3) and (3, 3)
在同一行或者同一列的‘ C '的对数
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
int x,y;
}p[100100];
char map[110][110];
int main()
{
int cnt,n;
while(scanf("%d",&n)!=EOF)
{
cnt=0;
memset(map,0,sizeof(map));
for(int i=0;i<n;i++)
{
scanf("%s",map[i]);
for(int j=0;j<n;j++)
{
if(map[i][j]=='C')
{
p[cnt].x=i;
p[cnt++].y=j;
}
}
}
int ans=0;
for(int i=0;i<cnt;i++)
{
for(int j=0;j<cnt;j++)
{
if(i==j) continue;
if(p[i].x==p[j].x||p[i].y==p[j].y)
ans++;
}
}
printf("%d\n",ans/2);
}
return 0;
}

Codeforces--629A--Far Relative’s Birthday Cake(暴力模拟)的更多相关文章

  1. codeforces 629A Far Relative’s Birthday Cake

    A. Far Relative’s Birthday Cake time limit per test 1 second memory limit per test 256 megabytes inp ...

  2. Codeforces Round #343 (Div. 2)-629A. Far Relative’s Birthday Cake 629B. Far Relative’s Problem

    A. Far Relative's Birthday Cake time limit per test 1 second memory limit per test 256 megabytes inp ...

  3. Codeforces Round #369 (Div. 2) A B 暴力 模拟

    A. Bus to Udayland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake【暴力/组合数】

    A. Far Relative’s Birthday Cake time limit per test 1 second memory limit per test 256 megabytes inp ...

  5. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake 水题

    A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Do ...

  6. Codeforces 629 A. Far Relative’s Birthday Cake

      A. Far Relative’s Birthday Cake   time limit per test 1 second memory limit per test 256 megabytes ...

  7. codeforces 887B Cubes for Masha 两种暴力

    B. Cubes for Masha time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  8. bnuoj 20832 Calculating Yuan Fen(暴力模拟)

    http://www.bnuoj.com/bnuoj/problem_show.php?pid=20832 [题意]: 给你一串字符串,求一个ST(0<ST<=10000),对字符串中字符 ...

  9. POJ 1013 小水题 暴力模拟

    Counterfeit Dollar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 35774   Accepted: 11 ...

随机推荐

  1. Ubuntu16安装jdk8配置Tomcat9

    一.配置jdk 1.下载解压是肯定不能少的 2.配置环境变量根据自己需求来 export JAVA_HOME=/usr/software/jdk1.8.0_121 export CLASSPATH=. ...

  2. DeltaFish 校园物资共享平台 第八次小组会议

    DeltaFish 校园物资共享平台 第八次小组会议 记录人:娄雨禛 2018.7.31 会议总结 1. 对前端界面进行改进,具体改进内容如下: 2. 后端从登录和注册的具体实现做起,熟悉流程之后完成 ...

  3. oracle sql*loader的使用

    用法: SQLLDR keyword=value [,keyword=value,...] 有效的关键字:     userid -- ORACLE 用户名/口令    control -- 控制文件 ...

  4. appium 使用send_keys方法时报错: driver.find_element_by_id("com.hmkx.zgjkj:id/layout_search_bar_input").send_keys("123")

    新手 使用send_keys方法时一直报错,上网查这个方法的用法,看着大家都是这么写的啊,后来直接搜索 报错信息,搜索结果的针对性就清楚多了. 原来是seleium版本太高导致的问题. 可以先在cmd ...

  5. mha0.56版本安装使用排错

    1.master_check_ssh --conf=/etc/app1.conf   这个检查就报错的我觉得百分之九十都是ssh之间连接问题.务必要保证各节点之间都可以免秘钥访问!     2.mas ...

  6. 如何区分null和undefined

    null和undefined是两种数据类型, 如果硬要区分的话. null是一种类型, 赋值变量为null型. 未定义的变量, 即为undefined. var a = null a // null ...

  7. solaris roles cannot login directly

    oracle@solaris:~$ su - root Password: Oracle Corporation SunOS root@solaris:~# cat /etc/user_attr # ...

  8. Django REST framework 渲染器、版本

    渲染器.版本: # settings.py REST_FRAMEWORK = { "DEFAULT_RENDERER_CLASSES": [ "rest_framewor ...

  9. bytes类型和python中编码的转换方法

    一.bytes类型 bytes类型是指一堆字节的集合,在python中以b开头的字符串都是bytes类型.例如: >>> a = "中国" >>> ...

  10. 学习C语言偶遇【斐波那契数列】

    1.今天学着学着就发现一个特别有趣的数列,斐波那契数列,感觉很好玩,翠花,上代码~~~~~~~ #include <stdio.h> int fibonaci(int i) { ) { ; ...