-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path343A.cpp
More file actions
51 lines (46 loc) · 894 Bytes
/
Copy path343A.cpp
File metadata and controls
51 lines (46 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<iostream>
#include<stdio.h>
using namespace std;
string s[105];
int check(int n){
int tot = 0;
tot = n*(n+1);
tot = tot / 2;
return tot;
}
int row(int n){
int total = 0;
int cnt = 0;
for(int i=0;i<n;i++){
cnt = 0;
for(int j=0;j<n;j++){
if(s[i][j]=='C') cnt++;
}
total = total + check(cnt-1);
}
return total;
}
int col(int n){
int total = 0;
int cnt = 0;
for(int i=0;i<n;i++){
cnt = 0;
for(int j=0;j<n;j++){
if(s[j][i]=='C') cnt++;
}
total = total + check(cnt-1);
}
return total;
}
int main(){
int n,ans;
while(cin>>n){
for(int i=0;i<n;i++){
cin>>s[i];
}
ans = 0;
ans = ans + row(n);
ans = ans + col(n);
cout<<ans<<endl;
}
}