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.io.*; import java.util.*; public class Cf629A { public static void main(String args[]) throws IOException { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); int n = in.nextInt(); char c[][] = new char[n][n]; boolean vi...
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.io.*; import java.util.concurrent.TimeUnit; public class birthdayCake { public static void main (String [] args) throws Exception { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStream...
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 G[101][101]; int col[101]; int main() { memset(col, 0, 101 * sizeof(int)); int n; cin >> n; long long ans = 0; for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < n; j++) { cin >> G[i][j]; if (G[i][j] == 'C') { 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 comb(int n) { return (n * (n - 1)) / 2; } int main() { int n; cin >> n; char a[n][n]; int ans = 0, count = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> a[i][j]; if (a[i][j] == 'C') { count++; } } 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()) l=[] c=0 for i in range(n): l.append(list(input())) for i in range(n): for j in range(n-1): for k in range(j+1,n): if(l[i][j]==l[i][k]=="C"): c+=1 for i in range(n): for j in range(n-1): for k in range(j+1,n): if(l[j][i]==l[k][i]=="C"): c+=1 print(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 ...
from collections import defaultdict n=int(raw_input()) row= defaultdict(int) column = defaultdict(int) for i in range (0,n): l=list(raw_input()) for j in range (0,n): if l[j] == 'C': row[i] += 1 column[j] += 1 s = 0 for x in row.values(): s += x*(x-1)/2 for x in column.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 ...
CHOCOLATE = 'C' def total_pairs(cake): total = 0 for row in cake: total += num_pairs(row.count(CHOCOLATE)) for c in range(len(cake)): total += num_pairs(sum(row[c] == CHOCOLATE for row in cake)) return total def num_pairs(num): return sum(num - i - 1 for i in range(num - 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 ...
n = (int)(input()) s = [ input() for i in range(n)] ans = 0 for i in range(n): for j in range(n): if s[i][j] == 'C': for k in range(j+1, n): if s[i][k] == 'C': ans += 1 for i in range(n): for j in range(n): if s[j][i] == 'C': for k in range(j+1, n): if s[k][i] == 'C': ans += 1 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; long long int a, b, d, n, m, k, l, g; char c[105][105]; int main() { cin >> n; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> c[i][j]; for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < n; j++) cnt += (c[i][j] == 'C'); b += ...
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 BirthdayCake { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); int[][] m = new int[n][n]; int finalCount = 0; for (int i = 0; i < n; i++) { 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 ...
row = [0] * 110 col = [0] * 110 N = int(raw_input()) for i in range(N) : S = raw_input() for j in range(N): if S[j] == 'C': row[i] += 1 col[j] += 1 sum = 0 for i in range(N) : sum += row[i] * (row[i] - 1) / 2 sum += col[i] * (col[i] - 1) / 2 print sum
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 Main { public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int n = sc.nextInt(); boolean[][] arr = new boolean[n][n]; for (int i = 0; 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 ...
import java.util.*; import java.io.*; //x5668 public class A629 { public static void main(String[]args) { Scanner reader = new Scanner(System.in); int n = reader.nextInt(); int output = 0; String [][]cells = new String[n][n]; for(int r=0;r<n;r++) { String temp ...
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 N = 5000 + 5; const int mod = 1e9 + 7; int dp1[200], dp2[2000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; string ch[n + 1]; for (int i = 0; i < n; i++) { cin >> ch[i]; } int cnt = 0, 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(input()) ans=0 l=[[0]*n for i in range(n)] for i in range(n): s=input() for j in range(n): l[i][j]=s[j] for i in range(n): t=0 for j in range(n): if l[i][j]=='C': t+=1 ans+=t*(t-1)//2 for j in range(n): t=0 for i in range(n): if l[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 ...
n = int(input()) g, r, c = [input() for i in range(n)], [0] * n, [0] * n for i in range(n): for j in range(n): if g[i][j] == 'C': r[i] += 1 c[j] += 1 print(sum(x * (x - 1) // 2 for x in r + 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.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; //Codeforces Round 343 public class A { public static void main(String[] args) throws IOException { MyScanner sc = new MyScanne...
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 c(m, k): rez = 1 i = 0 while i < k: rez *= m - i i += 1 i = 1 while i <= k: rez /= i i += 1 return rez n = int(raw_input()) cake = [] for j in xrange(n): stroke = raw_input() stroke = stroke.replace('.', '0') stroke = stroke.replace('C', '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 ...
def C(n): return n*(n-1)//2 n = int(input()) a = n * [0] for i in range(n): a[i] = input() ans = 0 for i in range(n): q, w = 0, 0 for j in range(n): if a[i][j] == 'C': q += 1 if a[j][i] == 'C': w += 1 ans += C(q) + C(w) 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 ...
from itertools import product, chain n = int(input()) cake = [list(input()) for _ in range(n)] choc_row, choc_col = [0] * n, [0] * n for r, c in product(range(n), repeat=2): if cake[r][c] == 'C': choc_row[r] += 1 choc_col[c] += 1 ans = sum(c * (c - 1) // 2 for c in chain(choc_row, choc_col)) 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 ...
n = int(input()) l = [] ans = 0 for _ in range(n): l.append(input()) for k in l: c = k.count('C') ans += (c ** 2 - c)//2 for i in range(n): for j in range(n): if l[j][i] == 'C': for k in range(j+1,n): if l[k][i] == 'C': ans += 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 ...
#!/usr/bin/env python3 import collections if __name__ == '__main__': N = int(input()) grid = [input() for _ in range(N)] cols = collections.Counter() rows = collections.Counter() for i, r in enumerate(grid): for j, c in enumerate(r): if c == 'C': cols[j] += 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 ...
n = int(input()) a = [0]*100 result = 0 for _ in range(n): line = input() c = line.count("C") result += c*(c-1)//2 for i in range(len(line)): a[i] += 1 if line[i] == 'C' else 0 for e in a: result += e*(e-1)//2 print(result)
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.lang.*; import java.util.*; import java.io.*; public class test { int a[],b[]; Scanner sc=new Scanner(System.in); PrintWriter pr=new PrintWriter(System.out,true); public static void main(String... args) { test c=new test(); c.prop(); } public void prop() { int n,sum=0,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 math def nCr(n,r): if n-r == 0 : return 1 f = math.factorial return f(n) // f(r) // f(n-r) def solve(arr): count = 0 for i in range(len(arr)): #row count_row_c = arr[i].count('C') if count_row_c >= 2 : count += nCr(count_row_c, 2) #col count_col_c = 0 for 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 int fact(long long int n) { if (n == 1 || n == 0) return 1; return n * fact(n - 1); } long long int nCr(long long int n, long long int r) { long long int n_fact, r_fact, n_r_fact; n_fact = fact(n); r_fact = fact(r); n_r_fact = fact(n - r); return (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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Farrelativesbirthdaycake { public static void main(String args[]) throws NumberFormatException, IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parse...
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; long long i = 0, j = 0, k = 0; long long a = 0, b = 0, c = 0; char ch; string s; string rr = "RR"; string gg = "GG"; string bb = "BB"; vector<long long> v; set<char> se; long long dateb[1000][1000]; long long row[1000]; long long col[1000]; long long date[1000]...
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()) m = [] for _ in range(n): m.append(input()) ans = 0 # row for i in range(n): cnt = 0 for j in range(n): if m[i][j] == 'C': cnt += 1 ans += cnt * (cnt - 1) // 2 # col for i in range(n): cnt = 0 for j in range(n): if m[j][i] == 'C': cnt += 1 ans += cnt * (cnt - 1) // 2 p...
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 fact(n): if n == 0: return 1 return n * fact(n-1) cake = [] chk = 0 for _ in range(int(input())): s = input() c = s.count('C') chk += fact(c)//(2 * fact(c-2)) if c > 1 else 0 cake.append(s) cake = zip(*cake) for s in cake: c = s.count('C') chk += fact(c)//(2 * fact(c - 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(raw_input()) lst = [] ans = 0 for i in range(n): temp = raw_input() lst.append(temp) lst2 = lst for i in range(n): Cs = lst[i].count('C') ans += (Cs*(Cs-1))/2 lst2 = zip(*lst) for i in range(n): Cs = lst2[i].count('C') ans += (Cs*(Cs-1))/2 print (int(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(input()) a = [list(input()) for i in range(n)] s = 0 for i in a: v = 0 for j in i: if(j == 'C'): v+=1 s += (v * (v-1))//2 for i in range(n): v = 0 for j in range(n): if(a[j][i] == 'C'): v+=1 s += (v * (v -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 ...
n = int(input()) s = [list(input()) for i in range(n)] count = 0 for i in range(n): count+=(s[i].count('C')*(s[i].count('C')-1)//2) for j in range(n): count1 = 0 for i in range(n): if s[i][j]=='C': count1+=1 count+=((count1*(count1-1))//2) print(count)
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 TaskA { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); String[] cake = new String[n]; for (int i = 0; i < n; i++) { cake[i] = scan.next(); } int rows[] = new...
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 str[100 + 7]; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; for (__typeof(n) i = (0); i < (n); i++) { cin >> str[i]; } int res = 0; for (__typeof(n) i = (0); i < (n); i++) { int cnt = 0; for (__typeof(n) 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(raw_input()) cake = [[False for x in xrange(n)] for x in xrange(n)] for i in xrange(n): temp = raw_input() for j in xrange(n): if temp[j] == "C": cake[i][j] = True out = 0 for i in xrange(n): for j in xrange(n): if cake[i][j]: for k in xrange(i+1, n): if cake[k][j]: out += 1 for k in 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.*; import java.math.BigInteger; import java.util.*; public class ChoclateInCakes { public static void main(String[] args) { FScanner in = new FScanner(); int size = in.nextInt(); char[][] board = new char[size][size]; int[] happyCol = new int[size]; 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 ...
#!/usr/bin/python3 class StdReader: def read_int(self): return int(self.read_string()) def read_ints(self, sep = None): return [int(i) for i in self.read_strings(sep)] def read_float(self): return float(self.read_string()) def read_floats(self, sep = None): return [float(i) for i in self.read_strings(se...
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.io.*; public class Far_Relatives_Birthday_Cake { public static void main(String args[]) throws Exception { BufferedReader f=new BufferedReader(new InputStreamReader(System.in)); // BufferedReader f=new BufferedReader(new FileReader("Far_Relatives_Birthday_Cake.in")); int runs=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()) p_r=0 p_c=0 arr=[0 for i in range(n)] for t in range(n): c_C=0 column=-1 row=input() for c in row: column+=1 if c=="C": c_C+=1 arr[column]+=1 if c_C!=0: p_r+=sum([i for i in range(c_C)]) for m in range(n): if arr[m] !=0: 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, count, ans = 0; cin >> n; char arr[n][n]; for (int i = 0; i < n; i++) { count = 0; for (int j = 0; j < n; j++) { cin >> arr[i][j]; if (arr[i][j] == 'C') count++; } ans += count * (count - 1) / 2; } for (int i = 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 N = 1e2 + 7; string s[N]; int row[N], col[N]; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n; cin >> n; for (int i = (0); i < (n); ++i) cin >> s[i]; for (int i = (0); i < (n); ++i) 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; const int N = 100; int n; char s[N][N]; void input() { cin >> n; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> s[i][j]; } void output() { int ans = 0; for (int i = 0; i < n; i++) { int a = 0, b = 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 choose(int n, int k) { if (k == 0) return 1; return (n * choose(n - 1, k - 1)) / k; } int main() { int n; cin >> n; char c; int fila[n + 1], columna[n + 1]; fill(fila, fila + n + 1, 0); fill(columna, columna + n + 1, 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 ...
def binom(n, k): ans = 1 for i in range(k): ans = (ans * (n - i)) // (i + 1) return ans n = int(input()) cake = [input() for row in range(n)] pairs = sum([binom(row.count('C'), 2) for row in cake]) pairs += sum([binom(col.count('C'), 2) for col in [[row[i] for row in cake] for i in range(n)]]) 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.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class A { static StringTokenizer st; static BufferedReader br; static PrintWriter pw; ...
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; /** * Created on 10:44 07/02/2020 * Description: * * @author Weleness */ public class Main { private static int n; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); sc.nextLine(); char[][] f = new ch...
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.InputStream; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws IOException { Reader.init(System.in); int n = Reader.nextInt(); 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 combin(int c) { int ans = 0; for (int i = c - 1; i >= 1;) { ans += i; i--; } return ans; } int main() { int const maxx = 105; int n; cin >> n; int rc, cc; rc = cc = 0; int ans = 0; char arr[maxx][maxx]; for (int i = 0; i < n; 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 ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String args[]) { InputStream intputStream = System.in; Out...
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, r[105], c[105], a[105][105]; long long ans, f[105][105]; char s[105]; void biao() { for (int i = 1; i <= 100; i++) { f[i][0] = f[i][i] = 1; for (int j = 1; j < i; j++) f[i][j] = f[i - 1][j] + f[i - 1][j - 1]; } } int main() { biao(); scanf("%d", &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(raw_input()) c = [] for i in range(n): r = [] for j in raw_input(): r.append(j) c.append(r) ans = 0 for i in range(n): t = 0 for j in range(n): if c[i][j] == 'C': t += 1 if t >= 2: ans += t*(t-1)/2 for i in range(n): t = 0 for j 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 ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(reader.readLine()); char[][] array = ...
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 mat=[] for i in range(n): x=input() yo=x.count('C') ans+=(yo*(yo-1)//2) mat.append(x) for i in range(n): count=0 for j in range(n): if mat[j][i]=='C': count+=1 ans+=(count*(count-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 = input() a = [list(raw_input()) for _ in range(n)] b = zip(*a) res = 0 for i in range(n): c = a[i].count('C') d = b[i].count('C') res += (c-1)*c/2 + (d-1)*d/2 print res
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()) r = 0 stlpce = [0 for i in range(n)] for i in range(n): line = input() riadok = 0 for j, c in enumerate(line): if c == 'C': riadok += 1 stlpce[j] += 1 r += riadok * (riadok - 1) // 2 for stlpec in stlpce: r += stlpec * (stlpec - 1) // 2 print(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; char c[10001][10001]; long long sum = 0; int main() { int i, j, k, n, l; cin >> n; for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) cin >> c[i][j]; for (i = 1; i <= n; i++) { k = 0; l = 0; for (j = 1; j <= n; j++) { if (c[i][j] == 'C') 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 ...
# Description of the problem can be found at http://codeforces.com/problemset/problem/629/A def comb(N,k): # from scipy.comb(), but MODIFIED! if (k > N) or (N < 0) or (k < 0): return 0 N,k = map(int,(N,k)) top = N val = 1 while (top > (N-k)): val *= top top -= 1 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 ...
n=int(input()) a=list() for i in range(n): a.append(input()) k=h=0 for i in range(n): for j in a[i]: if(j=='C'): h+=1 k+=round(h*(h-1)/2) h=0 for i in range(n): for j in range(n): if(a[j][i]=='C'): h+=1 k+=round(h*(h-1)/2) h=0 print(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 ...
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; @SuppressWarnings("unchecked") public class P629A { public void run() throws Exception { int n = nextInt(); int [] rows = new int [n]; int [] cols = new int [n]; for (int r = 0; r < n; r++) { String s = 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 ...
#include <bits/stdc++.h> using namespace std; long long operation(long long a) { long long h = (a * (a - 1)) / 2; return h; } int main() { long long a; cin >> a; char matriz[a][a]; for (long long i = 0; i < a; i++) { for (long long j = 0; j < a; j++) { char g; cin >> g; matriz[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 ...
def fact(k): if k==0:return 0 return k+fact(k-1) n=int(input());arr=[] for _ in range(n): s=[i for i in input()];arr.append(s) ans=0 #row for i in range(n): cnt=0 for j in range(n): if arr[i][j]=='C':cnt+=1 if cnt>=1:ans+=fact(cnt-1);k1=fact(cnt-1) #col for i in range(n): cnt=0 for j in range(n): if 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 ...
import java.util.*; public class helloWorld { static ArrayList<Integer> ar; 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 str = in.next(); for(int j = 0; 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; using ll = long long; using ld = long double; using ii = pair<ll, ll>; using vi = vector<ll>; using vb = vector<bool>; using vvi = vector<vi>; using vii = vector<ii>; using vvii = vector<vii>; const int INF = 2000000000; const ll LLINF = 9000000000000000000; int main() { ...
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 DEBUG = 0; namespace defs { int read() { int aa, bb = 1, ch; while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-') ; ch == '-' ? aa = 0, bb = -1 : aa = ch - '0'; while (ch = getchar(), ch >= '0' && ch <= '9') aa = aa * 10 + ch - '0'; return aa ...
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 arr[105][105]; int main() { long long n, t = 0, ans = 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++) { ans = 0; for (int j = 0; j < n; j++) { if (arr[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; bool parz(int k) { for (int j = 2; j <= sqrt(k); j++) { if (k % j == 0) return false; } return true; } struct araj { string x; int y, z; }; char a[101][101]; int b[1001]; int main() { int c = 0, d, e = 0, q, i, j, k, l, m, n, v = 0, t = 0; int s1 = 0, s2 =...
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=input() m=[] cnt=0 for i in range(n): a=map(str,raw_input()) t=a.count('C') cnt+=t*(t-1)/2 m.append(a) for i in range(n): t=0 for j in range(n): if m[j][i]=='C': t+=1 cnt+=t*(t-1)/2 print cnt
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()) result = 0 L = [0 for i in range(n)] for i in range(n): r = 0 T = [s for s in input()] for j in range(n): if T[j] == "C": r += 1 L[j] += 1 result += (r*(r-1))//2 for k in L: result += (k*(k-1))//2 print(result)
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 Main{ public static void main(String[] args){ Scanner cin=new Scanner(System.in); long r[]=new long[105]; long c[]=new long[105]; int n=cin.nextInt(),i,j,k; for(i=0;i<n;i++){ String str=cin.next(); for(j=0;j<n;j++){ if(str.charAt(j)=='C') { r[i]++; c[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() { long long int n, m, z, x, k, l, s = 0, y, c = 0, i, j; cin >> n; char a[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { cin >> a[i][j]; } } for (i = 0; i < n; i++) { c = 0; for (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 ...
def pscl(num,l=[1]): for i in range(num): l = map(lambda x,y:x+y,[0]+l,l+[0]) return l n=int(raw_input()) d={i:0 for i in range(n)} ans=chk=0 for i in range(n): s=raw_input() t=s.count('C') if t>1: ans+=pscl(t)[2] for a,j in enumerate(s): if j=='C': d[a]+=1 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 ...
""" https://codeforces.com/problemset/problem/629/A """ def getPairs(n): pairs = 0 for x in range(1, n): pairs += x return pairs n = int(input()) # base cases pairings = [0, 1] cols = [0] * n rows = [0] * n cake = [] for i in range(0, n): cake.append(list(input())) for x in range(0, n): for y in range(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 ...
import math n=eval(input()) i=0 ans=0 s='' x='' while(i<n): s=input() if(s.count('C')>=2): ans+=s.count('C')*(s.count('C')-1)//2 x=x+s i+=1 i=0 f='' g=0 while(g<n): i=g f='' while(i<len(x)): f+=x[i] i+=n if(f.count('C')>=2): ans+=f.count('C')*(f.count('C')-1)//2 g+=1 pr...
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()) x=[] y1=[0 for i in range(n)] y2=[0 for i in range(n)] for i in range(n): x.append(list(input())) for i in range(n): for j in range(n): if x[i][j]=="C": y1[i]+=1 y2[j]+=1 ans=0 for i in range(n): if y1[i]>1: ans+=y1[i]*(y1[i]-1)//2 if y2[i]>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; string str[105]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { cin >> str[i]; } int row[105]; int col[105]; int ans = 0; for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < n; j++) { if (str[i][j] == 'C') cnt...
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()) c = [raw_input() for _ in xrange(n)] rows = [0] * n cols = [0] * n for i in xrange(n): for j in xrange(n): if c[i][j] == 'C': rows[i] += 1 cols[j] += 1 ans = sum(map(lambda r: r*(r-1)//2, rows)) ans += sum(map(lambda c: c*(c-1)//2, cols)) 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() { 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 ...
import java.util.Scanner; public class a { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(),t=0; String[] s=new String[n]; for(int i=0;i<n;i++) s[i]=sc.next(); for(int i=0;i<n;i++) t+=su(no(s[i])); for(int i=0;i<n;i++) { int c=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; int n; char mp[111][111]; long long col[111]; long long row[111]; int main() { cin >> n; cin.get(); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cin >> mp[i][j]; if (mp[i][j] == 'C') { col[j]++; row[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 ...
lst=[] b=0 n=0 s=0 v=[100] z=int(input()) for x in range(z): c=list(map(str,input())) e=c.count('C') #s+=1 lst.append(c) d=e-1 while d>0: n+=d d-=1 #print('n*n*n*n*n*',n) #print('lst=',lst) for m in range(z): for a in lst: if a[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 ...
# import sys import math # sys.stdin=open("input1.in","r") # sys.stdout=open("output2.out","w") N=int(input()) L=[] for i in range(N): L.append(list(input())) sum=0 for i in range(N): count1=0 count2=0 for j in range(N): if L[i][j]=="C": count1+=1 if count1>=2: sum+=int(math.factorial(count1)/math.factorial...
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 r629a { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] rows = new int[n]; int[] cols = new int[n]; for (int i = 0; i<n; i++) { String nextRow = sc.next(); for (int j = 0; j<n; j++) { if (nextRow.charAt(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 java.io.*; import java.util.StringTokenizer; public class prog { MyScanner in; PrintWriter out; public void solve() throws IOException { int n = in.nextInt(); String arr[] = new String[n]; for (int i = 0; i < n; i++) { arr[i] = in.nextToken(); } int count = 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 ...
#!/usr/bin/env python3 N = int(input()) grid = [input() for _ in range(N)] rows = [0 for _ in range(N)] cols = [0 for _ in range(N)] for i in range(N): for j in range(N): if grid[i][j] == 'C': rows[i] += 1 cols[j] += 1 # def blah(n): return n*(n-1)//2 total = sum(map(blah, 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 ...
n=int(input()) cake=[] ans=0 for i in range(n): layers=input() tmp=((layers.count("C")-1)*(layers.count("C")))//2 ans+=tmp x=list(layers) cake.append(x) cake=list(zip(*cake)) for i in range(n): tmp=cake[i].count("C") ans+=(((tmp-1)*(tmp))//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(input()) text = [list(input()) for i in range(n)] rez = 0 for i in text: a = i.count('C') rez += a * (a - 1) // 2 for i in range(n): a = 0 for j in range(n): if text[j][i] == 'C': a += 1 rez += a * (a - 1) // 2 print(rez)
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 A629 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); char[][] a = new char[n][n]; for(int i = 0; i<n; i++) a[i] = input.next().toCharArray(); int[] rs = new int[n], cs = new int[n]; for(int i = 0; i<n; i++) 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 ...
import java.io.*; import java.util.*; import java.math.*; public class Main implements Runnable { public BufferedReader in; public PrintWriter out; public StringTokenizer tok; public void solve() throws Exception { int n = nextInt(); String[] a = new String[n]; for (int i = 0; i < n; ++i) { a[i] = nex...
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=[] x=0 for i in range(n): l.append(input()) for i in range(n): c=0 for j in range(n): if(l[i][j]=='C'): c+=1 x+=(c*(c-1))//2 for i in range(n): c=0 for j in range(n): if(l[j][i]=='C'): c+=1 x+=(c*(c-1))//2 print(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 ...
x,n,s=[],0,0 for i in range(int(input())): temp=input() x.append(temp) n=temp.count("C") if(n>1): s=s+(n*(n-1)//2) m=0 for i in range(len(x)): for j in x: if j[i]=="C": m+=1 if m>1: s=s+(m*(m-1)//2) m=0 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 ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, i, j, c = 0, c1; string s; vector<string> v; cin >> n; for (i = 0; i < n; i++) { cin >> s; v.push_back(s); c1 = 0; for (j = 0; j < n; j++) { if (s[j] == 'C') c1++; }...
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 cake { public static int dool (int a) { int x = (a*(a-1))/2; return x; } public static void main(String[] args) { Scanner scanner = new Scanner (System.in); int n =scanner.nextInt(),sum=0,ans=0; char [][] a; a= new char [n][n]; for (int i=0;i<n;i++) { String s = scanne...
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 Main { static char[][] arr; static int count = 0; public static void main(String[] args) { // TODO Auto-generated method stub Scanner can = new Scanner(System.in); int n = can.nextInt(); arr = new char[n][n]; can.nextLine(); for (int i = 0; i < arr.length; 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 count(string s) { int c = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == 'C') c++; } return c * (c - 1) / 2; } int main() { int n; cin >> n; string a[n]; int c = 0; for (int i = 0; i < n; i++) { cin >> a[i]; c += count(a[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 ...
def nCr(n , r): return (fact(n) // (fact(r) * fact(n - r))) def fact(n): res = 1 for i in range(2 , n + 1): res = res * i return res a=[] n=int(input()) for i in range(n): a.append(input()) ans=0 for i in range(n): aa=0 for j in range(n): if a[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; void PD() { cout.precision(18); cout << fixed; } void NPT() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); } int n, i, j, k, ans; string s[105]; int main() { cin >> n; for (i = 0; i < n; ++i) cin >> s[i]; for (i = 0; i < n; ++i) { k = 0; fo...
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.io.*; public class Solution { public static PrintWriter w = new PrintWriter(System.out); public static void main(String args[] ) throws Exception { Reader in = new Reader(); int n = in.nextInt(); char[][] arr = new char[n][n]; for (int i=0; i<n; i++) { arr[i] = in.next().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 ...
def fac(n): fact=1 for i in range(n,0,-1): fact*=i return fact n=int(input()) l=[] for i in range(n): s=list(input()) l.append(s) a=[] b=[] r=[] c=[] ans=0 for i in range(n): c=0 for j in range(n): if l[i][j]=='C': c+=1 a.append(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 i, j, k; int count, sum; int n, m, p, t; vector<int> v; int maxi, mini; int tc; string s, r; int lens, lenr; cin >> n; string cake[n]; for (i = 0; i < n; i++) { cin >> cake[i]; } count = 0; for (i = 0; i < n; i++) { for (...