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 ...
#include <bits/stdc++.h> using namespace std; struct st { int x; int y; }; bool fun(const st &a, const st &b) { return a.x < b.x; } int main() { long long t, ans, i, j, x, n; char str[105][105]; t = 1; while (t--) { cin >> n; for (i = 0; i < n; i++) { scanf("%s", str[i]); } ans = 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 main(void) { ios_base::sync_with_stdio(false); int i, f, g; int n; cin >> n >> ws; string a[n + 10]; for (i = 0; i <= n - 1; i += 1) { cin >> a[i]; } long long int result = 0; for (i = 0; i <= n - 1; i += 1) { int chocolateInRow = 0; int 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 ...
#include <bits/stdc++.h> using namespace std; char s[105][105]; int main() { int n; while (~scanf("%d", &n)) { int ans = 0; for (int i = 0; i < n; i++) scanf("%s", s[i]); for (int i = 0; i < n; i++) { int x = 0; for (int j = 0; j < n; j++) { if (s[i][j] == 'C') { 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 ...
from itertools import chain count_pairs = lambda n: n * (n - 1) // 2 cake = [input() for _ in range(int(input()))] print(sum(count_pairs(line.count('C')) for line in chain(cake, zip(*cake))))
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 factorial(n): if n < 2: return 1 return n * factorial(n - 1) def nchoosek(n, k): return factorial(n) // (factorial(k) * factorial(n - k)) def pairCount(arr): count = 0 for i in range(len(arr)): currentCount = 0 for j in range(len(arr[0])): 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 ...
n=int(input()) cake=[] vert=["" for i in range(n)] ans=0 for i in range(n): y=input() for j in range(len(y)): vert[j]+=y[j] p=y.count("C") ans+=(p*(p-1)//2) for i in vert: n=i.count("C") ans+=(n*(n-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> const int SZ = 1e2 + 5; const long long MD = 1e9 + 7; using namespace std; char arr[SZ][SZ]; int sum1[SZ], sum2[SZ]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { cin >> arr[i][j]; if (arr[i][j] == 'C') sum1[i]++, sum2[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 split(word): return list(word) 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 n=int(input()) r=dict() c=0 a=[] for i in range(n): a.append(0) for i in ra...
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, a, b; int main() { char s[105][105]; long long ans = 0; long long n; cin >> n; for (int i = 0; i < n; i++) { scanf("%s", s[i]); } for (int i = 0; i < n; i++) { int r = 0, c = 0; for (int j = 0; j < n; j++) { if (s[i][j] == 'C') 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 ...
import java.util.Scanner; public class BirthdayCake { public static int calculate(int[][] arr, int n) { int total = 0; for (int i = 0; i < n; i++) { int count1 = 0; int count2 = 0; for (int j = 0; j < n; j++) { if (arr[i][j] == 1) { count1++; } if (arr[j][i] == 1) { count2++; }...
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 double PI = acos(-1.0); const double eps = 1e-9; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; const int maxn = 1100000; const int maxm = 2e3 + 100; inline int read() { char ch = getchar(); int x = 0, f = 1; while (ch < '0' || ch > '9') {...
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__ = '11x256' n = int(raw_input()) v = [] count = 0 for i in range(0,n): v.append(raw_input()) for i in range(0,n): t1 = 0 t2 = 0 for j in range(0,n): if v[i][j]=='C': t1+=1 if v[j][i]== 'C': t2+=1 if t1 > 1: count += t1 * (t1-1) * 0.5 ...
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 ...
/* TEST CASE input 3 .CC C.. C.C output 4 input 4 CC.. C..C .CC. .CC. output 9 */ function main() { var n = parseInt(readline()); var answer = 0; var cakesInRow = new Array(n); var cakesInCol = new Array(n); var i, j; for (i = 0; i < n; i++) { cakesInRow[i] = 0; cakesInCol[i] = 0; } for (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 ...
n = input() c = [] for i in range(n): c.append(raw_input()) t=0 for r in c: n = r.count('C') t+=(n * (n-1)) / 2 for j in range(len(c[0])): cnt=0 for i in range(len(c)): if c[i][j]=='C': cnt+=1 t+=(cnt*(cnt-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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0, a[105] = {0}; cin >> n; string s; for (int i = 0; i < n; i++) { cin >> s; int tem = 0; for (int i = 0; i < s.size(); i++) if (s[i] == 'C') { tem++; a[i]++; } ans += tem * (tem - 1) / 2; } 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()) ans=0 a=['']*(n) for i in range(n): a[i]+=(input()) z=a[i].count('C') if z>1: x=1 for i in range(z-1,z+1): x*=i ans+=(x/2) #print(ans) b=['']*n for i in range(n): for j in range(n): b[i]+=a[j][i] z=b[i].count('C') if z>1: x=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.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Bit...
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()) b = [] for i in range(n): b += [input()] ans = 0 for j in range(n): s = 0 for i in range(n): if (b[j][i] == 'C'): s +=1 ans += s*(s-1)/2 s = 0 for i in range(n): if (b[i][j] == 'C'): s +=1 ans += s*(s-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()) g = [list(input()) for _ in range(n)] ret = 0 for i in range(n): for j in range(n): if g[i][j] != "C": continue for x in range(j+1, n): ret += g[i][x] == "C" for y in range(i+1, n): ret += g[y][j] == "C" print(ret)
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 Solution{ public static void main(String args[]){ Scanner sc= new Scanner(System.in); int n= sc.nextInt();int count=0,C=0; int c[][]= new int[n][n]; for(int i=0;i<n;i++) { String s=sc.next(); int k=0; for(int j=0;j<n;j++){ c[i][j]=s.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.BufferedReader; import java.io.InputStreamReader; public class A { static long nCk(long n, long k) { if (k > n) return 0; if (k * 2 > n) k = n - k; if (k == 0) return 1; long result = n; for (int i = 2; i <= k; ++i) { result *= (n - i + 1); result /= i; } return 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 ...
n=input() l=[] for i in range(n): s=raw_input() l.append(s) a=0 b=0 for i in range(n): for j in range(n-1): for k in range(j+1,n): if(l[i][j]=='.'): continue if(l[i][j]==l[i][k]): a=a+1 for i in range(n): for j in range(n-1): for 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.util.*; import static java.lang.Math.*; public class Main { static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(strea...
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, sum = 0, count; char letter; int col[100]; cin >> n; for (int i = 0; i < n; i++) col[i] = 0; for (int i = 0; i < n; i++) { count = 0; for (int j = 0; j < n; j++) { cin >> letter; if (letter == 'C') { 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 ...
// template halnix16 import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { static BufferedReader br; public static void main(String[] args) throws Exception { // write your code here br = new BufferedReader(new InputStreamReader(System.in)); int 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; long long n, a[300], b[300], z; char f; int main() { cin >> n; for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) { cin >> f; if (f == 'C') { z += a[i]; a[i]++; z += b[j]; b[j]++; } } } 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.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long res = 0; int[] col = new int[n]; for (int i = 0; i < n; ++i) { String s = in.next(); int count = 0; for (int j = 0; j < s.length(); ++j) { char ch = 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; template <typename T> ostream& operator<<(ostream& os, vector<T>& cont) { for (auto it : cont) { os << it << " "; } return (os << endl); } int main() { int N; cin >> N; vector<int> h(N, 0), v(N, 0); for (int i = 0; i < N; ++i) { string s; cin >> 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()) rows = [] for x in range(n): string = input() row = list(string) rows.append(row) columns = [[x[y] for x in rows] for y in range(n)] a = 0 for x in rows: b = x.count("C") a += b * (b - 1) // 2 for x in columns: b = x.count("C") a += b * (b - 1) // 2 print(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 ...
n = int(input()) cake = [] for i in range(n): s = input() cake.append(s) count = 0 for i in range(n): for j in range(n): if cake[i][j] == '.': continue # row for k in range(j + 1, n): if cake[i][k] == 'C': count += 1 # column ...
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, ans = 0; cin >> n; string s[n]; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { char ch; cin >> ch; s[i].push_back(ch); } } for (int i = 0; i < n; ++i) { int c = 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 java.util.Scanner; public class main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[][] cake = new char[n][n]; int happiness = 0; for (int i = 0; i < n; i++) { String s= sc.next(); cake[i] = s.toCharArray(); int count = 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 ...
n = int(input()) a = [] for i in range(n): a.append(list(input())) ans = 0 for i in range(n): t = 0 for j in range(n): if a[i][j] == 'C': t += 1 ans += t * (t - 1) // 2 for i in range(n): t = 0 for j in range(n): if a[j][i] == 'C': t += 1 ans += t * (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.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.Serializable; import java.math.*; import java.util.*; import java.lang.*; public class Solver{ InputReader in; Printer out; public void startTask() thro...
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 ...
# your code goes here n = int(raw_input()) arr=[] def f(a): return (a*(a-1)/2) for i in range(n): s = raw_input() temp=[] for j in s: temp.append(j) arr.append(temp) rows=[0]*n cols=[0]*n for i in range(n): for j in range(n): if arr[i][j] == 'C': rows[i]+=1 cols[j]+=1 ans = 0 for i in range(n): 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 ...
import math def c(n): x = n*(n-1)//2 return x n = int(input()) a = [[1 for j in range(n)] for i in range(n)] for i in range(n): s = input() for j in range(n): if s[j] == '.': a[i][j] = 0 x = 0 for i in range(n): k = a[i].count(1) x += c(k) for j in range(n): k = 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 ...
n = int(input()) init = [] for i in range(n): x = input() init.append(x) a = [] total_sum, i = 1, 2 while i < 100: a.append(total_sum) total_sum += i i += 1 ans = 0 for j in range(n): if init[j].count('C') > 1: ans += a[init[j].count('C') - 2] abc = 0 for k in range(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; unsigned long long countWays(int number) { return number * (number - 1) / 2; } int main() { int n; cin >> n; char **matr = new char *[n]; for (int i = 0; i < n; i++) matr[i] = new char[n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> matr[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, ans; int main() { cin >> n; vector<vector<char>> cake(n + 1, vector<char>(n + 1)); for (int i(1); i <= n; i++) { for (int j(1); j <= n; j++) { cin >> cake[i][j]; } } for (int i(1); i <= n; i++) { int ctr(0); for (int j(1); 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 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 ...
# cf 629 A 800 import math n = int(input()) M = [] for _ in range(n): M.append(input()) ans = 0 for i in range(n): row = M[i].count('C') if row >= 2: ans += math.factorial(row) / (math.factorial(row - 2) * 2) c = 0 for j in range(n): if M[j][i] == 'C': c += 1 if 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 f(n): return n*(n-1) // 2 n = int(input()) ss = [] rx = [] for i in range(n): s = input() x = s.count("C") rx.append(x) ss.append(s) cx = [] for j in range(n): c = 0 for i in range(n): if ss[i][j] == "C": c += 1 cx.append(c) r = 0 for x in rx: if 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 ...
n = int(raw_input()) result = 0 col_counts = [ 0 for i in range(n) ] for r in range(n): row = raw_input().strip() for c, ch in enumerate(row): if ch == 'C': col_counts[c] += 1 x = row.count('C') result += x * (x - 1) // 2 for x in col_counts: result += x * (x - 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 ...
#include <bits/stdc++.h> const int dx[] = {0, -1, 0, 1, -1, 1, 1, -1, -2, -2, 2, 2, -1, -1, 1, 1}; const int dy[] = {-1, 0, 1, 0, 1, 1, -1, -1, -1, 1, -1, 1, -2, 2, -2, 2}; using namespace std; int main(int argc, char const *argv[]) { int x; scanf("%d", &x); vector<string> in(x); for (int i = 0; i < x; i++) cin...
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 = [] for i in range(n): s.append(input()) counter = 0 for i in range(n): x = y = 0 for j in range(n): x += s[i][j] == 'C' y += s[j][i] == 'C' counter += x * (x-1) // 2+y * (y-1)//2 print(counter) # # CodeForcesian # ♥ # خیلی وقته دارم رو این سوال کار میکنم # تا به یک...
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 cal(int n) { return (n * (n - 1)) / 2; } int n, col[105], row[105]; string s[105]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { cin >> s[i]; for (int j = 0; j < n; j++) { if (s[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; vector<long long> v; char arr[400][400]; int main() { std::ios::sync_with_stdio(false); long long n; cin >> n; for (long long i = (long long)(1); i <= (long long)(n); i++) { for (long long j = (long long)(1); j <= (long long)(n); j++) { cin >> 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; const int N = 102; char s[N][N]; int n; int main() { int i, j, k; long long res = 0; cin >> n; for (i = 0; i < n; i++) cin >> s[i]; for (i = 0; i < n; i++) { k = 0; for (j = 0; j < n; j++) if (s[i][j] == 'C') k++; res += k * (k - 1) / 2; } 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 ...
n = int(input()) G = [] for i in range(n): G.append(list(input())) row_cnt = [0 for r in range(n)] col_cnt = [0 for c in range(n)] for r in range(n): for c in range(n): if G[r][c] == 'C': row_cnt[r] += 1 col_cnt[c] += 1 pairs = 0 for i in range(n): pairs += int((row_cnt[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.*; import java.util.*; public class Cake { public static int calNumOfChocalatePair(int chocalate) { int i = 1, j = 2, counter = 2, c = chocalate; while(j+1 <= c) { i += counter; counter++; j++; } return i; } public static v...
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 A { public static void main(String[] args) throws IOException { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader bf =new BufferedReader(isr); int a =Integer.parseInt(bf.readLine()); char[][] chars = new char[a][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 ...
n=int(input()) k=[] ans=0 for i in range(n): k.append(input()) z=tuple(zip(*k)) for i in range(n): x=k[i].count("C") y=z[i].count("C") ans+=x*(x-1)//2+y*(y-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 ...
var n = Number(readline()); var tab = new Array(n); for (var i = 0; i < n; ++i) { tab[i] = readline(); } var sum = 0; for (var i = 0; i < n; ++i) { var num = 0; for (var j = 0; j < n; ++j) { if (tab[i][j] === "C") { ++num; } } sum += num * (num - 1) / 2; } for (var 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 ...
def nCr(n, r): return int(fact(n) / (fact(r)* fact(n - r))) # Returns factorial of n def fact(n): res = 1 for i in range(2, n+1): res = res * i return res n = int(input()) l = [] for _ in range(n): x = list(input()) l.append(x) ans = 0 for i in range(n): h = l[i] ans += nCr(...
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> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,fma") using namespace std; const long long N = 10 * 1e4 + 1; const long long mod = 1e9 + 7; const long long INF = 1e10; const long long M = (1 << 17) + 1; const long long LL = 1; long long n; char 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> #pragma comment(linker, "/STACK:16777216") using namespace std; int main() { ios_base::sync_with_stdio(0); long long n; vector<string> a(105); vector<long long> b(105, 0), c(105, 0); cin >> n; for (long long i = 0; i < n; i++) { cin >> a[i]; for (long long 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 ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; char a[105][105]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j]; long long res = 0; for (int i = 0; i < n; i++) { long long int sum = 0; 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 ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, ans = 0; cin >> n; string ar[n]; for (int i = 0; i < n; i++) { cin >> ar[i]; } for (int i = 0; i < n; i++) { int c = 0; for (int j = 0; j < n; j++) { if (ar[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 arrange(int a, int c) { if (a == 2) return 1; if (a == 3) return 3; int temp = c; int multipul = a * (a - 1); return multipul / 2; } int main() { int pairs = 0; char cake[100][100] = {}; int n; cin >> n; for (int i = 0; i < n; i++) for (int j = 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 java.io.BufferedReader; import java.io.InputStreamReader; import java.math.BigInteger; import java.io.IOException; public class ClassA { public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { int n = Integer.parseInt(br.readLine().trim()...
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()) s = 0 c = [0]*n for _ in xrange(n): c1 = raw_input() s1 = 0 for i in xrange(n): if c1[i]=='C': s1+=1 c[i]+=1 s+=s1*(s1-1)/2 #print s #print c for _ in xrange(n): s += 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 ...
#include <bits/stdc++.h> using namespace std; char ch[101][101]; int main() { int i, j, n, ans = 0; cin >> n; for (i = 0; i < n; i++) cin >> ch[i]; for (i = 0; i < n; i++) { int cnt = 0, cnt2 = 0; for (j = 0; j < n; j++) { if (ch[i][j] == 'C') cnt++; if (ch[j][i] == 'C') cnt2++; } 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> using namespace std; const long long MOD = 1000000007; const long long N = 100000; template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; for (auto it = v.begin(); it != v.end(); ++it) { if (it != v.begin()) os << ", "; os << *it; } return os << ...
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=1 while t>0: n=int(raw_input()) row=[0]*n col=[0]*n for i in range(n): a=raw_input() for j in range(n): if a[j]=="C": row[i]+=1 col[j]+=1 r=0 for i in range(n): if row[i]>1: x=row[i] r+=((x*(x-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> using namespace std; long long n, m, x, y, t, ans, res, sum, mn = 1e9, cnt, mx, k, z, mnn = 1e9, mxx, b = 1, i, r; string s1, s3, s2, s; set<int> st; pair<int, int> p[1000001]; vector<int> v, v1, v3, v4, v2; map<char, long long> mp, mpp; char c, d, a; boo...
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/python # -*- coding: UTF-8 -*- vis = [0]*110 while True: try: num = map(int, raw_input().split()) except: break n=num[0] s = [[0 for col in range(110)] for row in range(110)] ans=0 for i in range(0,n): s[i] = raw_input() for i in range(0,n): cnt = 0 for j in range(0,n): if(s[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()) mat=[] rowc=0 for i in range(n): l=list(input()) mat.append(l) z=l.count('C') rowc+=z*(z-1)//2 colc=0 for j in range(n): z=0 for i in range(n): if mat[i][j]=='C': z+=1 colc+=z*(z-1)//2 print(rowc+colc)
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 combinations n = int(input()) cake = [0]*n count = 0 for _ in range(n): row = list(map(lambda x: 1 if x == "C" else 0, list(input()))) c = row.count(1) count += len(list(combinations((range(1, c+1)), 2))) new = [] for i, j in zip(cake, row): new.append(i+j) cake ...
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 ...
ITER = input() FIELDX = [] for i in range(ITER): FIELDX.append(raw_input()) FIELDY = ["" for i in range(ITER)] for i in range(ITER): for j in range(ITER): FIELDY[i] += FIELDX[j][i] X_NUM = [0 for i in range(ITER)] for i in range(ITER): for j in range(ITER): if FIELDX[i][j] == "C": X_NUM[i] += 1 Y_NUM = [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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> all(n); int sum = 0; for (int i = 0; i < n; i++) cin >> all[i]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int c = j + 1; c < n; c++) if (all[i][j] == all[i][c] && all[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; long long perm(int n) { if (n <= 1) { return 0; } else { return n * (n - 1) / 2; } } int main() { int n; cin >> n; char a[n][n]; int k[n]; for (int i = 0; i < n; i++) { int sum = 0; for (int j = 0; j < n; j++) { cin >> a[i][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 ...
n = input() l = [] for i in range (n): a = raw_input() b = [] for i in a: b.append(i) l.append(b) def fact(v): m = 1 for i in range (1,v+1): m = i * m return m def bionom(x,n):# Choose x from n numerator = fact(n) denominator = fact(x)*fact(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> int main() { int n, a, i, x; int res = 0; scanf("%d", &n); char matriz[n][n]; for (i = 0; i < n; i++) { getchar(); for (x = 0; x < n; x++) { scanf("%c", &matriz[i][x]); } } for (a = 0; a < n; a++) { for (i = 0; i < n - 1; i++) { for (x = i + 1; x < n; 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 sinp(): return raw_input() def iinp(): return int(sinp()) def intl(): return map(int, sinp().split()) n = iinp() li=[] ans=0 for i in xrange(n): li.append(sinp()) for i in xrange(n): c = 0 for j in xrange(n): if li[i][j]=='C': c+=1 if c<2: continue...
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 by andrew on 3/22/16. */ public class B { public static int val (int n) { return n * (n-1) / 2; } public static void main (String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); char[][] m = new cha...
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 factor(n): res = 1 for i in range(1, n+1): res *= i return res n = int(input()) p = [] res = 0 for i in range(n): p.append(list(input())) c = p[i].count('C') res += factor(c)/(2*factor(c-2)) if c > 1 else 0 for col in list(zip(*p)): c = col.count('C') res += factor...
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(n): return (n * (n - 1)) // 2 n = int(input()) ver = [0] * n gor = [0] * n for i in range(n): lst = input() for j in range(n): if lst[j] == 'C': gor[i] += 1 ver[j] += 1 ans = 0 for i in ver: ans += f(i) for i in gor: ans += f(i) 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()) l='' happiness=0 for _ in range(n): l+=input() for i in range(n): start=i*n end=start+n count=l[start:end].count('C') happiness+=(count*(count-1))/2 for i in range(n): string='' for j in range(i,n*n,n): string+=l[j] count=string.count('C') happiness+=(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 ...
#include <bits/stdc++.h> using namespace std; bool f(vector<int> a, vector<int> b) { if (a[0] - a[1] < b[0] - b[1]) { return 1; } return 0; } int main() { long long n, ans = 0; cin >> n; vector<int> v1(n), v(n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { char c; cin >>...
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, n, k, cnt = 0; char v[101][101]; cin >> n; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) cin >> v[i][j]; } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { for (k = i + 1; k < n; k++) { if (v[i][j] == 'C' && (v...
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 a[105]; int b[105]; int num[105]; int sovle(int n) { num[2] = 1; for (int i = 3; i <= n; i++) { num[i] = num[i - 1] + i - 1; } return num[n]; } int main() { int n, m; scanf("%d", &n); int i, j; for (i = 0; i < n; i++) { scanf(...
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=[input() for i in range(n)] total=0 l1=[] for i in range(n): s="" for j in range(n): s+=l[j][i] l1.append(s) for i in range(len(l)): a=l[i].count("C") b=l1[i].count("C") if a >= 2: if a == 2: total+=1 else: total+=(a-1)*(a)//2 if b >= 2: if b == 2: total+=1 else: total+=(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 ...
#include <bits/stdc++.h> using namespace std; map<long long, long long> r, c; int main() { int n; char ch; cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { cin >> ch; if (ch == 'C') { r[i]++; c[j]++; } } int ans = 0; for (int i = 1; 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.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; public class bdaycake { public static void main(String[] args)throws Exception{ InputReader in = new InputReader(System.in); PrintWriter pw = new PrintWriter(System.out); 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 ...
from collections import * from math import * from itertools import * import os import sys from io import BytesIO, IOBase def splint(): return map(int, input().split()) def PRINT(check:bool, first:str, second:str): print(first if check else second) # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlin...
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 a[200][200]; while (cin >> n) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> a[i][j]; } } int sum = 0; int con = 0; int i = 0, j = 0; for (i = 0; i < n; i++) { for (j = 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 def nCr(n, r): return (math.factorial(n) / (math.factorial(r)* math.factorial(n - r))) n=int(input()) l=[] for i in range(n): l.append(input()) k1=0 k2=0 for i in range(n): c1=0 for j in range(n): if(l[i][j]=='C'): c1=c1+1 if(c1>=2): k1=k1+nCr(c1,2) for i in range(n): c2=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 ...
def Chocolate(): n = int(raw_input()) cake = [] for i in range(n): cake.append(raw_input()) pairs = 0 for i in range(n): cakes = 0 for j in range(n): if cake[j][i] == 'C': cakes += 1 pairs += (cakes*(cakes-1))/2 for i 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 ...
#include <bits/stdc++.h> int n, col[105], row[105], ans; char c; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { scanf("\n%c", &c); if (c == 'C') ans += col[j]++ + row[i]++; } printf("%d\n", ans); scanf("\n"); return 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 ...
n = input() s = list() for i in range(n): si = raw_input()[:n] s.append(si) c = 0 for i in range(n): for j in range(n): if i == n-1 and j == n-1: break if s[i][j] == 'C': for k in range(j+1,n): if s[i][k] == 'C': c+=1 for k in range(i+1,n): if s[k][j] == '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 ...
#include <bits/stdc++.h> using namespace std; template <class T> void chmin(T& a, const T& b) { if (a > b) a = b; } template <class T> void chmax(T& a, const T& b) { if (a < b) a = b; } int n; string s[105]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) cin >> s[i]; int ans = 0; 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 ...
from sys import stdin as fin # fin = open("cfr343a.in", "r") n = int(fin.readline()) cols = [0] * n sum = 0 for i in range(n): c = j = 0 for sym in fin.readline().rstrip(): if sym == 'C': c += 1 cols[j] += 1 j += 1 # print(c, (c * (c - 1)) // 2) sum += (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 ...
#include <bits/stdc++.h> using namespace std; int lin[200], col[200], i, l, c, n, s; char x; int main() { cin >> n; for (l = 1; l <= n; l++) { for (c = 1; c <= n; c++) { cin >> x; if (x == 'C') { lin[l]++; col[c]++; } } } for (i = 1; i <= n; i++) s = s + lin[i] * (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 ...
#include <bits/stdc++.h> using namespace std; char a[100 + 5][100 + 5]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { scanf("%s", a[i]); } int ans = 0; for (int i = 0; i < n; i++) { int tmp = 0; for (int j = 0; j < n; j++) { if (a[i][j] == 'C') tmp++; } ans += (tmp * ...
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=[] for i in range(0,n): q=input() s.append(q) r=[0 for x in range(0,101)] c=[0 for x in range(0,101)] for i in range(0,n): for j in range(0,n): if s[i][j]=='C': r[i]+=1 c[j]+=1 h=0 for i in range(0,n): h+=(r[i]*(r[i]-1))/2 for i in range(0,n): h+=(c[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 ...
x=int(input()) sum=0 l=[[*input()] for _ in range(x)] for i in range(x): tmp=l[i].count('C') sum+=tmp*(tmp-1)//2 l=list(zip(*l)) for i in range(x): tmp = l[i].count('C') sum += tmp * (tmp - 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 ...
#include <bits/stdc++.h> using namespace std; set<long long>::iterator it; vector<long long>::iterator it1; struct stc { int fir, sc; } input[1000]; bool comp(stc a, stc b) { return a.sc < b.sc; } template <class T> inline T BM(T p, T e, T M) { long long ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret...
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; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class _343_1 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub MyfScan...
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 <typename A, typename B> ostream& operator<<(ostream& o, pair<A, B> a) { return o << a.first << ' ' << a.second; } template <typename A, typename B> istream& operator>>(istream& o, pair<A, B>& a) { return o >> a.first >> a.second; } const int mod = 1e9 + 7, abc...
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::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long n, ans = 0; cin >> n; char a[n][n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j]; for (int i = 0; i < n; i++) { int counter = 0; for (int j = 0; j ...