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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

 

以上是关于Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake的主要内容,如果未能解决你的问题,请参考以下文章

343D/Codeforces Round #200 (Div. 1) D. Water Tree dfs序+数据结构

Codeforces Round #343 (Div. 2) (C. Famil Door and Brackets(DP))

Codeforces Round #343 (Div. 2) D. Babaei and Birthday Cake(线段树+离散化优化DP)

Codeforces Round #436 E. Fire(背包dp+输出路径)

[ACM]Codeforces Round #534 (Div. 2)

Codeforces 343D Water Tree(DFS序+线段树+技巧)