prompt
string
response
string
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class A341 { /** * @param args */ public static void main(String[] args) { Scanner sc= new Scanner(System.in); int n=sc.nextInt(); String[]a= new String[n]; for(in...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; long long n, m, x3, x, r_y, maxl, p1, p2, p1nach, pis, p2nach, t[1000][1000], l, r, k, st, sum, i, j; char c; int main() { cin >> n; for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) { cin >> c; if (c == 'C') t[i][j] = 1; } for (i = 1; i <= n; ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int fact(int n) { if (n == 1 || n == 0) return 1; return n * fact(n - 1); } int C(int n, int k) { return (n * (n - 1)) / 2; } int main() { char** A; int n; int sum = 0; cin >> n; A = new char*[n]; for (int i = 0; i < n; i++) { A[i] = new char[n + 1]; ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int per(int &n) { int ans = 1; return ans / 2; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; char a; vector<char> v; vector<vector<char>> vv; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> a; ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = "RDLU"; long long ln, lk, lm; char s[105][105]; int cal(int x) { return x * (x - 1) / 2; } void fmain() { scanf("%d", &n); for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%s", ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import math def C(n, r): f = math.factorial return f(n) / f(n - r) / f(r) n = int(raw_input().rstrip()) a = [[0] * n for i in range(n)] for i in range(n): s = raw_input().rstrip() for j in range(n): if s[j] == 'C': a[i][j] = 1 else: a[i][j] = 0 ans = 0 for i in range(n): m = sum(a[i]) if m > 1: an...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> int main() { int n, i, j, A[110], B[110], sum; char a; while (scanf("%d", &n) != EOF) { getchar(); for (i = 1; i <= n; i++) { A[i] = 0; B[i] = 0; } for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { a = getchar(); if (a == 'C') { ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.io.File; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Scanner; public class A { public static void main(String[] args) throws FileNotFoundException { //File inFile = new File("./src/a.txt"); Scanner in; in = new Scanner(System.in); in...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n = int(input()) a = [['.'] * n for i in range(n)] for i in range(n): a[i] = list(input()) c1 = 0 for i in range(n): c = 0 for j in range(n): if a[i][j] == 'C': c += 1 c1 += (c * (c - 1)) // 2 for i in range(n): c = 0 for j in range(n): if a[j][i] == 'C': ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int n = 0; cin >> n; int total = 0; string grid[n]; for (int i = 0; i < n; i++) { cin >> grid[i]; } for (int i = 0; i < n; i++) { int r = 0; for (int j = 0; j < n; j++) { if (grid[i][j] == 'C') { r++; } } to...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.io.*; import java.util.*; public class Solution { static class Task { public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.nextInt(); char[][] mat = new char[n][]; for (int i = 0; i < n; ++i) { String buf = in.next(...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
a=int(input()) c=[[] for i in range(a)] h=0 for i in range(a): b=input() for j in range(a): c[j].append(b[j]) for k in range(b.count('C')): h+=k for i in range(a): for j in range(c[i].count('C')): h+=j print(h)
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; /** * * @author TPardabekov */ public ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n = int(input()) k = [[[(1 if i=='C' else 0) for i in j] for j in input().split()][0] for _ in range(n)] def comb(x): return x * (x-1) // 2 j = [[] for _ in range(n)] for i in range(n): for z in range(n): j[i].append(k[z][i]) print(sum([comb(z.count(1)) for z in k]) + sum([comb(z.count(1)) for z in j]))...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools import random sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return list(map(int, sys.stdin.r...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 123; const int mod = 1e9 + 7; const int INF = 1e9 + 1; struct node { int num; char c; } a[101][101]; bool x[10001][10001]; long long n, k, sum, ans; void check(int d, int first) { for (int i = 1; i <= n; i++) { if (a[d][i].c == 'C' && i != f...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n=int(input("")) arr=[] for i in range(n): value=str(input("")) arr.append(value) count=0 for i in range(0,n): for j in range(0,n-1): for k in range(j+1,n): if((arr[i])[j]==(arr[i])[k] and (arr[i])[j]=='C'): count+=1 if((arr[j])[i]==(arr[k])[i] and (arr[j])[i]=='C')...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.util.*; public class birthdayCake{ public static void main(String args[]){ Scanner myS = new Scanner(System.in); int n = myS.nextInt(); int rowCount[] = new int[n]; int colCount[] = new int[n]; for(int i=0; i<n; i++){ String inputData = myS.next(); for(int j=0; j<n; j++){ if(Charact...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigmod(T b, T p, T m) { T ret; if (p == 0) return 1; if (p & 1) { ret = (bigmod(b, p / 2, m) % m); return ((b % m) * ret * ret) % m; } else { ret = (bigmod(b, p / 2, m) % m); return (ret * ret) % m; } } int dx4[] = {1, -...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
// Name: Dr Jonathan Cazalas // Date: // Description: import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { FastInputReader in = new FastInputReader(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); long happine...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n = int(input()) pole = [] ans = 0 for i in range(n): s = input() h = 0 for j in s: if j == 'C': h += 1 ans += (h * (h - 1) // 2) pole.append(s) for i in range(n): h = 0 for j in range(n): if pole[j][i] == 'C': h += 1 ans += (h * (h - 1) // 2) prin...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
from math import factorial n = int(input()) cake = [] for _ in range(n): cakeLine = [] for i in (input().replace('.', '0').replace('C', '1')): cakeLine.append(int(i)) cake.append(cakeLine) lines = [] for i in range(n): lines.append(sum(cake[i])) lines.append(sum(list(zip(*cake))[i])) a = 0...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
__author__ = 'Azad' r = int(raw_input()) l =[] for x in range(r): l.append(raw_input()) w = [ x.count('C') for x in l] l = zip(*l) w.extend([ x.count('C') for x in l]) e = [x*(x-1)/2 for x in w] print sum(e)
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, sum = 0, num; cin >> n; char a[n][n]; for (i = 0; i < n; i++) { num = 0; for (j = 0; j < n; j++) { cin >> a[i][j]; if (a[i][j] == 'C') { num++; } } sum = sum + (num * (num - 1)) / 2; } for (i = ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n= int(input()) matrix = [ [ 'c' for i in range(n) ] for j in range(n)] for i in range(n): matrix[i]=list(input()) #print(matrix) ans=0 for i in range(n): count=0 for j in range(n): if matrix[i][j]=='C': count=count+1 ans=ans+(count*(count-1))/2 for i in range(n): count=0 ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; char s[120][120]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%s", s[i]); int tot = 0; long long ans = 0; for (int i = 0; i < n; i++) { int tot = 0; for (int j = 0; j < n; j++) if (s[i][j] == 'C') tot++; ans += tot *...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; char arr[n + 2][n + 2]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cin >> arr[i][j]; } } int row = 0, ans = 0; for (int i = 1; i <= n; i++) { row = 0; for (i...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int n, c = 0; cin >> n; char a[n][n]; int ans = 0, i, j; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) cin >> a[i][j]; } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (a[i][j] == 'C') c++; } ans = ans + (c * (c -...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.util.Scanner; public class CF629A { public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int r = 0; char[][] c = new char[n][n]; for(int i = 0;i < n; i++){ c[i] = sc.next().toCharArray(); } ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.util.*; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int[] row = new int[N]; int[] col = new int[N]; for (int i = 0; i < N; i++) { String s = in.next(); for (int j = 0; j < N; j++) { if (s.charAt(j) == 'C') { ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Paglierino { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintW...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n = int(input()) l=[] def find(word): count=0 for i in word: if i=="C": count += 1 return(count) z=0 for i in range(n): l.append(input()) z += (find(l[i])*(find(l[i])-1))/2 for i in range(n): count=0 for y in range(n): ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n=int(input()) mat=['']*n r=0 for k in range(n): mat[k]=input() r+=(mat[k].count('C')*(mat[k].count('C')-1)/2) for k in range(n): c=0 for i in range(n): c+=(mat[i][k]=='C') r+=(c*(c-1)/2) print(int(r))
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; string a[105]; int main() { int n, ans = 0; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < n; j++) if (a[i][j] == 'C') cnt++; ans += (cnt - 1) * cnt / 2; cnt = 0; for (int j...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n = int(input()) grid = [input() for i in range(n)] ans = 0 for i in range(n): c = grid[i].count('C') ans += c * (c - 1) // 2 c = 0 for j in range(n): if grid[j][i] == 'C': c += 1 ans += c * (c - 1) // 2 print(ans)
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, a = -1, ans = 0, q; cin >> n; char arr[n][n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> arr[i][j]; for (int i = 0; i < n; i++) { a = -1, q = 0; for (int j = 0; j < n; j++) { if (arr[i][j] == 'C') { ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<char> > v; v.resize(n); for (int i = 0; i < n; i++) v[i].resize(n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> v[i][j]; } } long long answ = 0; for (int i = 0; i < n; i++) { ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Solution { private static long[][] binomial(int n) { long[][] c = new long[n + 1][n + 1]; for ( int i = 0; i <= n; i++) { for ( int j = 0; j <= i; j++) { if ( j == 0 || j == i)...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; long long ceiling(long long x, long long y) { if (x % y) return ((x / y) + 1); else return (x / y); } long long gcd(long long x, long long y) { return ((y == 0) ? x : gcd(y, x % y)); } long long lcm(long long x, long long y) { return ((x * y) / gcd(x, y)); } l...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
__author__ = 'vboldovs' import math def combination(n,m): if n <2: return 0 return math.factorial(n)/(math.factorial(n-m)*math.factorial(m)) cake_matrix = [] happiness = 0 n = int(input()) for i in range(n): cake_matrix.append(input()) #row calc for i in range(n): temp = 0 for j in range...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; void fast() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { int n, c = 0; char x; vector<pair<int, int> > v; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> x; if (x == 'C') { v.push_bac...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
__author__ = 'aste' def main(): n = int(input()) rows = [0] * n cols = [0] * n res = 0 for i in range(0, n): row = input() for j in range(0, n): if row[j] == 'C': res += rows[i] + cols[j] rows[i] += 1 cols[j] += 1 prin...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); static int n = sc.nextInt(); static int res = 0; static int i,j; static String[][] ary = new String[n][n]; static boolean[][] vis = new boolean[n][n]; public static void main(String[] args) { for(int i=0;i<n;i++){ S...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
def f(g): t=0 for v in g: x=v.count('C') t+=x*(x-1)/2 return t a=[raw_input() for _ in range(input())] print f(a)+f(zip(*a))
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; char cake[100][100]; int amount[100][100]; int happiness; int chocrow; int choccol; int dimension; int main() { cin >> dimension; for (int i = 0; i < dimension; i++) { for (int j = 0; j < dimension; j++) { cin >> cake[i][j]; } } for (int i = 0; i < dim...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class A629 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; char str[105][105]; int main() { int n, res = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> str[i]; } for (int i = 0; i < n; i++) { int temp = 0; for (int j = 0; j < n; j++) { if (str[i][j] != '.') temp++; } res += temp * (temp - 1) /...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; char s[120][120]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%s", s[i]); int a = 0; long long sum = 0; for (int i = 0; i < n; i++) { int a = 0; for (int j = 0; j < n; j++) if (s[i][j] == 'C') a++; sum += a * (a - 1)...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.util.*; public class Test { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] l = new int[n + n]; for(int i = 0; i < n; i++){ String s = sc.next(); for(int j = 0; j < s.length(); j++){ if(s.charAt(j) == 'C'){ l[i]++; l[n +...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
l=[] n=int(input()) for i in range(n): l.append([0]*n) for i in range(n): for row,d in enumerate(input()): l[i][row]=d count=0 for i in range(n): x=0 for j in range(n): if l[i][j] is 'C': x+=1 x=x*(x-1)/2 count+=x for i in range(n): x=0 ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5; int row[MAX]; int col[MAX]; int main() { int N; cin >> N; char X[N + 99][N + 99]; for (int A = 1; A <= N; A++) for (int B = 1; B <= N; B++) { cin >> X[A][B]; if (X[A][B] == 'C') row[A]++, col[B]++; } int ans = 0; for (int...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import math n=int(input()) matrix=[] for i in range(n): s=str(input()) a=[] a.append(s) matrix.append(a) c=0 d=0 f=0 count=0 z=0 b=0 for i in range(0,len(matrix)): c=(matrix[i][0].count("C")) if(c>=2): d=d+(math.factorial(c)//(math.factorial(2)*math.factorial(c-2))) while(count<(n*n)): ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.util.*; public class bucky{ public static void main (String args[]) { Scanner input=new Scanner(System.in); HashMap<Integer, Integer> map= new HashMap<Integer, Integer>(); String nn=input.next(); int n=Integer.parseInt(nn); int j; String nums[]=new String[n]; for(int i=0;i<n;i++...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.io.*; public class A629 { public static void main(String[] ar) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[][] cake = new int[n][n]; for(int i=0; i<n; i++) { String row = br.readLine(); ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n = int(raw_input()) ans = 0 col_cnts = [0]*n for i in xrange(n): l = list(raw_input()) row_cnt = l.count("C") ans += row_cnt * (row_cnt - 1) / 2 for j in xrange(n): col_cnts[j] += 1 if l[j] == "C" else 0 for j in xrange(n): ans += col_cnts[j] * (col_cnts[j] - 1) / 2 print ans
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n = int(raw_input()) res = 0 arr = [] for i in range(n): arr.append(0) for i in range(n): temp = [] chocs = 0 cell = raw_input() for j in range(n): if cell[j] == "C": chocs += 1 arr[j] += 1 res += chocs*(chocs - 1) for i in range(n) : res += arr[i] * (arr[i] -...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int n, a[110][110], ans; int main() { cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { char c; cin >> c; a[i][j] = (c == 'C' ? 1 : 0); } } for (int i = 0; i < n; i++) { int s = 0; for (int j = 0; j < n; j++) { ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import sys N = int(sys.stdin.readline().strip()) cake = [[]*N for i in range(N)] for i in xrange(N): cake[i] = list(sys.stdin.readline().strip()) answer = 0 for i in xrange(N): chocolate = 0 for j in xrange(N): if cake[i][j] == 'C': chocolate += 1 if chocolate >= 2: answ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n=int(input()) lista=[] for x in range(n): l=input() lista.append(l) total=0 #print(lista) for x in range(n): elementol=0 elementoc=0 for y in lista[x]: if y == 'C': elementol+=1 subl=(elementol*(elementol-1))//2 total+=subl for z in range(n): if lista[z]...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n = int(input()) a = [0 for i in range(100)] ans = 0 for i in range(n): line = input() c = line.count("C") ans += c*(c-1)//2 for j in range(len(line)): if line[j] == 'C': a[j]+=1 for i in a: ans += i*(i-1)//2 print(ans)
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { signed long long int N; char Mass[100][100]; int I[100] = {0}; int J[100] = {0}; cin >> N; char t; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { cin >> t; Mass[i][j] = t; if (Mass[i][j] == 'C') { I[i]++;...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { long long n; char a[500][500]; cin >> n; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j]; int s = 0; int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] == 'C') s++; } i...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int n; char arr[105][105]; long long int ans = 0; long long int k = 0; cin >> n; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> arr[i][j]; for (int i = 0; i < n; i++) { k = 0; for (int j = 0; j < n; j++) { if (arr...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int n; int c[105] = {0}, r[105] = {0}; int i, j; char k; cin >> n; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { cin >> k; if (k == 'C') { r[i]++; c[j]++; } } } int ans = 0; for (i = 1; i <= n;...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int n; char c[105][105]; int row[105], col[105]; int sol; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", c[i]); } for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (c[i][j] == 'C') { row[i]++; col[j]++;...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> row(n); vector<int> col(n); long long sum = 0; for (int i = 0; i < n; ++i) { string s; cin >> s; for (int x = 0; x < s.size(); ++x) { if (s[x] == 'C') { col[i]++; row[x]++; } }...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.io.*; public class FarRelative { public static void main(String args[]) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); char c[][]= new char[t][t]; for(int o=0;o<t;o++){ c[o] =...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#a =[int(i) for i in input().split()] n=int(input()) a=[] t=0 for i in range(n): s=input() b=[] z=0 for j in s: b.append(j) if j=='C': z+=1 t+=(z-1)*z//2 a.append(b) for j in range(n): z=0 for i in range(n): if a[i][j]=='C': z+=1 t+=(z-...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int k, x; cin >> k; char c[k][k]; int count = 0; for (int i = 0; i < k; i++) { for (int j = 0; j < k; j++) { cin >> c[i][j]; } } for (int i = 0; i < k; i++) { for (int j = 0; j < k - 1; j++) { for (int m = j + 1; m < k; m++...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int res(int k) { int res = k * (k - 1) / 2; return res; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int rows = n, cols = n; vector<vector<char>> v(n); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { char...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long sum = 0; char arr[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> arr[i][j]; } } for (int i = 0; i < n; i++) { long long counter = 0; for (int j = 0; j < n; j++) { if...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { char s[101][101]; int n, ans = 0; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cin >> s[i][j]; } for (int i = 0; i < n; i++) { int c = 0; for (int j = 0; j < n; j++) if (s[i][j] == 'C') c++; ans += (c * (...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import operator as op # import sys # sys.stdin = open("a.test.txt") def read(): return raw_input() def horizontal(data): return [sum(1 for char in line if char == "C") for line in data] def vertical(data): return [sum(1 for char in line if char == "C") for line in zip(*data)] def factorial(n): retur...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.util.*; public class AAA { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int row[] = new int[n]; int column[] = new int[n]; for(int i = 0; i < n; i++) { String s = sc.next(); ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
t = [] n = int(input()) res = 0 for i in range(n): t.append(list(input())) count_C = 0 for j in range(n): if t[i][j] == 'C': count_C += 1 if count_C > 1: res += (count_C * (count_C - 1) // 2) for i in range(n): count_C = 0 for j in range(n): if t[j][i] == 'C'...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
# n = int(input()) # (n, k) = list(map(int, input().split())) # s = list(map(int, input().split())) n = int(input()) f = [] for i in range(n): f.append([ch for ch in input()]) result = 0 for i in range(n): s1 = '' s2 = '' for j in range(n): s1 += f[i][j] s2 += f[j][i] c1 = s1.cou...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.util.Arrays; import java.util.Scanner; //import java.util.Stack; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); StringBuilder sb=new StringBuilder(); // Stack <Character> a=new Stack <Character>(); int a=input.nextInt();...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { string currs = "", prevs = ""; int n; cin >> n; vector<vector<char> > cake(n, vector<char>(n, ' ')); long ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> cake[i][j]; } } for (int i = 0; i < n; i++) { ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int n; char mat[100][100]; scanf("%d ", &n); for (int i = 0; i < n; i++) scanf("%s", mat[i]); int ans = 0; for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < n; j++) cnt += mat[i][j] == 'C'; ans += cnt * (cnt - 1) / 2; } ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> int n; char map[105][105]; int row[105], col[105]; int main() { while (scanf("%d", &n) != EOF) { memset(row, 0, sizeof(row)); memset(col, 0, sizeof(col)); for (int i = 0; i < n; i++) scanf("%s", map[i]); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n = int(input()) ans = 0 p = [] for i in range(n): p.append(list(input())) s = p[i].count('C') ans += s * (s - 1) for i in range(n): col = 0 for t in range(n): if p[t][i] == 'C': col += 1 ans += col * (col - 1) print(ans // 2)
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n=int(input()) l=[] for i in range(n): s=input() a=[] for j in s: a.append(j) l.append(a) c=0 for i in l: p=i.count('C') c+=p*(p-1)/2 for j in range(n): cm=0 for i in range(n): if(l[i][j]=='C'): cm+=1 p=cm c+=p*(p-1)/2 print(int(c...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n = int(input()) mat = [input() for i in range(n)] row = {} col = {} for i in range(len(mat)): for j in range(len(mat[0])): if mat[i][j] == 'C': row[i] = row.get(i, 0) + 1 col[j] = col.get(j, 0) + 1 res = 0 for v in row.values(): res += (v * (v-1)) // 2 for v in col.values(): ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; char C[101][101]; unsigned long long chf[101]; unsigned long long chc[101]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); unsigned long long n; cin >> n; unsigned long long rta = 0; for (unsigned long long i = 0; i < n; i++) { cin >> C[i]; } for...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; char a[200][200]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { scanf(" %c", &a[i][j]); } } long long res = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] != '...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n = int(raw_input()) cake = [] for i in range(n): cake.append(raw_input()) total = 0 for r in range(n): count = cake[r].count('C') total += max(count * (count - 1) / 2, 0) for c in range(n): count = 0 for r in range(n): count += 1 if cake[r][c] == 'C' else 0 total += max(count * (cou...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
data = [] n = int(input()) for i in range(n): temp = input().strip() data.append(temp) ans = 0 for i in range(n): temp = data[i].count('C') ans += (temp*(temp-1))//2 for i in range(n): cnt = 0 for j in range(n): if data[j][i] == 'C': cnt += 1 ans += (cnt*(cnt-1))//2 print(ans)
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
a=[] s=0 n=int(input()) for _ in range(n): a.append(input()) for i in range(n): r=c=0 for j in range(n): if a[i][j]=='C': r+=1 if a[j][i]=='C': c+=1 s+=(r*(r-1))//2+(c*(c-1))//2 print(s)
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import math as m def C(r, n): return m.factorial(n) // (m.factorial(r) * m.factorial(max(0, n - r))) n = int(input()) a = [] res = 0 for i in range(n): t = input() a.append(t) c = 0 for j in range(n): if t[j] == 'C': c += 1 res += C(2, c) for i in range(n): c = 0 f...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int n; int br1[107]; int br2[107]; void input() { cin >> n; int i, j; string a; for (i = 0; i < n; i++) { cin >> a; for (j = 0; j < n; j++) { if (a[j] == 'C') { br1[i]++; br2[j]++; } } } } void solve() { int ans = 0; int...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n = int(input()) s = [] count = 0 for i in range(n): s.append(input()) for i in range(n): for j in range(n - 1): if s[i][j] == 'C': for k in range(j + 1, n): if s[i][k] == 'C': count += 1 for i in range(n - 1): for j in range(n): if s[i][j] == ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; const int maxn = 111; long long hang[maxn], lie[maxn], G[maxn][maxn], N; int main() { char c; scanf("%I64d", &N); memset(hang, 0, sizeof(hang)); for (int i = 1; i <= N; ++i) { for (int j = 1; j <= N; ++j) { c = getchar(); while (c != '.' && c != 'c' ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
# def fac(num): # if num>1: # return num*fac(num-1) # else: # return num import math def comb(num): f = math.factorial if num>1: return int(f(num)/(f(2)*f(num-2))) else: return 0 n = int(input()) sum_1 =0 arr = [0 for i in range(n)] for i in range(n): s = input() ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
n=int(input()) a=[] for i in range(n): a.append(input()) t=0 for i in range(n): b=a[i].count("C") t+=(b*(b-1))//2 for i in range(n): s=0 for j in range(n): if a[j][i]=="C": s+=1 t+=(s*(s-1))//2 print(t)
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int n, licznik = 0, zadowolenie = 0; cin >> n; char tablica[n][n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> tablica[i][j]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) if (tablica[i][j] == 'C') licznik+...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char s[n][n]; long long sum = 0; for (int i = 0; i < n; i++) { int k = 1, cnt = 0; for (int j = 0; j < n; j++) { cin >> s[i][j]; if (s[i][j] == 'C') { cnt++; if (cnt >= 2) { sum += k; ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char s[n][n]; for (int i = 0; i < n; i++) cin >> s[i]; int ans = 0; for (int i = 0; i < n; i++) { int coun = 0; for (int j = 0; j < n; j++) if (s[i][j] == 'c' || s[i][j] == 'C') coun++; ans += (coun * (coun - 1)) /...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
import java.util.Scanner; public class JavaApplication1 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int num ; num = in.nextInt(); long row[] = new long[num]; long col[] = new long[num]; long ans = 0 ; String line ; ...
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ...
#include <bits/stdc++.h> char s[110][110]; int x[110], y[110]; int main() { int n, ans = 0; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%s", s[i]); memset(x, 0, sizeof x); memset(y, 0, sizeof y); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (s[i][j] == 'C') x[i]++, y[j]++; ...