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 }

时间: 2024-10-17 02:44:57

Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake的相关文章

Codeforces Round #343 (Div. 2) B. Far Relative’s Problem

题意:n个人,在规定时间范围内,找到最多有多少对男女能一起出面. 思路:ans=max(2*min(一天中有多少个人能出面)) 1 #include<iostream> 2 #include<string> 3 #include<algorithm> 4 #include<cstdlib> 5 #include<cstdio> 6 #include<set> 7 #include<map> 8 #include<ve

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

题目链接:点击打开链接 题意:给你一个长度为m的只含()的括号串s, 要求在s两端在加两个串p和q, 使得总长度为n,并且平衡, 平衡是指任意前缀串的(都不少于), 并且整个串的(和)一样多. 思路:我们不难想到这样一个DP, d[i][j]表示长度为i的串,(比)多j个(或者)比(多j个, 是等价的)的方案数.  那么转移很简单: if(j > 0) d[i][j] += d[i-1][j-1] ;    d[i][j] += d[i-1][j+1]. 然后为了满足那两个条件, 我们计算出s串

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

题目链接:点击打开链接 题意:给出n个圆柱体的地面半径和高, 要求只能有一个直接放在桌子上, 其他的要放在他上面, 第i个能放在第j个上面的条件是:当且仅当第i个的体积大于第j个且j < i . 求能叠起来的最大体积. 思路:一看就是一个DP, 而且状态很容易表示, d[i]表示到第i个为止能得到的最大总体积.   转移到 max(d[j]) + a[i], (j < i && a[i] > a[j]).  但是n非常大, 显然要优化, 因为第二层循环所做的事情就是在i之

Codeforces Round #279 (Div. 2) ABCD

Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard input/

【排序】【规律】Codeforces Round #254 (Div. 2) - D. Rooter&#39;s Song

D. DZY Loves FFT Source http://codeforces.com/contest/445/problem/D Description Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w?×?h, represented by a re

Codeforces Round #259 (Div. 2) 题解

A. Little Pony and Crystal Mine time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Twilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n?>?1) is an n?×?n 

Codeforces Codeforces Round #484 (Div. 2) E. Billiard

Codeforces Codeforces Round #484 (Div. 2) E. Billiard 题目连接: http://codeforces.com/contest/982/problem/E Description Consider a billiard table of rectangular size $n \times m$ with four pockets. Let's introduce a coordinate system with the origin at t

Codeforces Round #576 (Div. 2) B - Water Lily

Codeforces Round #576 (Div. 2) B - Water Lily While sailing on a boat, Inessa noticed a beautiful water lily flower above the lake's surface. She came closer and it turned out that the lily was exactly H centimeters above the water surface. Inessa gr

Codeforces Round #428 (Div. 2)

Codeforces Round #428 (Div. 2) A    看懂题目意思就知道做了 #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define rep(i,a,b) for (int i=a; i<=b; ++i) #define per(i,b,a) for (int i=b; i>=a; --i