欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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;
}