Codeforces 629A Far Relative’s Birthday Cake
程序员文章站
2022-05-09 22:01:57
...
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int n;
char temp[105][105];
int ans;
int main() {
scanf("%d", &n);
getchar();
for (int i = 0;i < n;++i) {
scanf("%s", &temp[i]);
getchar();
}
for (int i = 0;i < n;++i) {
int cnt = 0;
for (int j = 0;j < n;++j) {
if (temp[i][j] == 'C') {
cnt++;
}
}
ans += ((cnt*(cnt - 1)) / 2);
}
for (int j = 0;j < n;++j) {
int cnt = 0;
for (int i = 0;i < n;++i) {
if (temp[i][j] == 'C') {
cnt++;
}
}
ans += ((cnt*(cnt - 1)) / 2);
}
printf("%d\n", ans);
//system("pause");
return 0;
}