题解 | #Birthday Cake#

Birthday Cake

https://ac.nowcoder.com/acm/problem/229265

题意

给你一个 的矩阵,然后那你计算每一行和每一列的巧克力对数

思路

暴力

代码

/**
 *    author: andif
 *    created: 23.08.2023 22:22:44
**/
#include<bits/stdc++.h>
using namespace std;

#define de(x) cerr << #x << " = " << x << endl
#define dd(x) cerr << #x << " = " << x << " "
#define rep(i, a, b) for(int i = a; i < b; ++i)
#define per(i, a, b) for(int i = a; i > b; --i)
#define mt(a, b) memset(a, b, sizeof(a))
#define sz(a) (int)a.size()
#define fi first
#define se second
#define qc ios_base::sync_with_stdio(0);cin.tie(0)
#define eb emplace_back
#define all(a) a.begin(), a.end()
using ll = long long;
using db = double;
using pii = pair<int, int>;
using pdd = pair<db, db>;
using pll = pair<ll, ll>;
using vi = vector<int>;
const db eps = 1e-9;

int main() {
    int n; cin >> n;
    vector<string> s(n);
    rep(i, 0, n) cin >> s[i];
    ll ans = 0;
    rep(i, 0, n) {
        int c = 0;
        rep(j, 0, n) c += s[i][j] == 'C';
        ans += c * (c - 1) / 2;
    }
    rep(j, 0, n) {
        int c = 0;
        rep(i, 0, n) c += s[i][j] == 'C';
        ans += c * (c - 1) / 2;
    }
    cout << ans << '\n';
    return 0;
}
全部评论

相关推荐

阿武同学:基本信息保留前面三行,其他的可以全部删掉,邮箱最重要的你没写,主修课程精简到8个以内,实习里面2/3/4都是水内容的,非要写的话建议两到三句话,项目经历排版优化下,自我评价缩到三行
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务