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

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

水题

 1 #include<iostream>
 2 #include<string>
 3 #include<algorithm>
 4 #include<cstdlib>
 5 #include<cstdio>
 6 #include<set>
 7 #include<map>
 8 #include<vector>
 9 #include<cstring>
10 #include<stack>
11 #include<cmath>
12 #include<queue>
13 #define clc(a,b) memset(a,b,sizeof(a))
14 #include <bits/stdc++.h>
15 using namespace std;
16 #define LL long long
17 
18 int main()
19 {
20     char s[110][110];
21     int n;
22     scanf("%d",&n);
23     for(int i=0;i<n;i++)
24         scanf("%s",&s[i]);
25     LL tot=0;
26     LL ans=0;
27     for(int i=0;i<n;i++)
28     {
29         tot=0;
30         for(int j=0;j<n;j++)
31         {
32             if(s[i][j]=='C')
33                 tot++;
34         }
35         ans+=tot*(tot-1)/2;
36         tot=0;
37         for(int j=0;j<n;j++)
38         {
39             if(s[j][i]=='C')
40                 tot++;
41         }
42         ans+=tot*(tot-1)/2;
43     }
44     cout<<ans<<endl;
45     return 0;
46 }
View Code